npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@openccw/sb3-crypto

v0.2.0

Published

快速解密或加密 CCW 的 sb3 文件,主要基于 Web Crypto API + JSZip 实现。

Readme

快速解密或加密 CCW 的 sb3 文件,主要基于 Web Crypto API + JSZip 实现。

在线使用: https://openccw.github.io/download-sb3/

[!NOTE]
sb3 文件名去掉结尾的 .sb3 扩展名之后,前 32 个字符会被作为解密时使用的密钥。
不得擅自重命名已加密的 sb3 文件。

安装

npm

npm i @openccw/sb3-crypto
import sb3Crypto from "@openccw/sb3-crypto";

其它包管理器

你也可以使用其它包管理器(例如 pnpmyarn)代替 npm

使用

解密

解密并返回 project.json

const projectLink = `https://m.ccw.site/user_projects_sb3/199431844/3c78eda3fb43e94c6b8cc892d493359b.sb3`

const projectLinkURL = new URL(projectLink)

// 从网络获取 sb3 文件。
// 文件名不是 MD5 ,同名文件的内容是可变的,所以不使用缓存。
projectLinkURL.searchParams.append('t', Date.now().toString())
const response = await fetch(projectLinkURL, { cache: 'no-store' })
if (!response.ok) {
    throw Error(`failed to fetch: HTTP ${response.status} ${response.statusText}`)
}
const data = await response.arrayBuffer()

// 更新 URL(跟随重定向)
projectLinkURL.href = response.url

// 解密并返回 project.json(类型:字符串)
const decryptedProjectJson = await sb3Crypto.decrypt.decryptToProjectJson(data, projectLinkURL.pathname)

console.log('project.json', decryptedProjectJson)

也可以解密并返回 sb3 文件:

// 解密并返回 sb3 (Uint8Array)
const decryptedSb3 = await sb3Crypto.decrypt.decryptToSb3(data, sb3FileName)

也可以解密并返回 JSZip 对象:

// 解密并返回 JSZip 对象
const decryptedZip = await sb3Crypto.decrypt.decryptToJszip(data, sb3FileName)

也可以解密后自己处理返回的数据:

/**
 * 解密,然后自己处理返回的数据。  
 * ⚠️ 更自由,但 **需要更谨慎** 。  
 * - 返回的 `sb3IsCopied`
 *   - `true` 则返回的 `sb3` 已拷贝(经过解密),  
 *     但这 **不能** 代表返回的 `sb3` 和 `zip` 里的 `project.json` 是正确的。  
 *   - `false` 则返回的 `sb3` 未经过拷贝(无需解密),它就是输入的 `data` 参数的值,  
 *     但这 **不能** 代表返回的 `sb3` 和 `zip` 里的 `project.json` 是正确的。  
 * - 返回的 `jsonIsDecrypted`
 *   - `true` 则返回的 `json` 是经过解密的,`sb3` 和 `zip` 里的 `project.json` 未解密,  
 *     需自行 `zip.file("project.json", json)` ,然后自行使用 `zip.generateAsync` 生成新的 `sb3` 。  
 *   - `false` 则 `json` 未加密,返回的 `sb3` 和 `zip` 里的 `project.json` 未加密。  
 */
const { sb3, sb3IsCopied, zip, json, jsonIsDecrypted } = await sb3Crypto.decrypt.prepareDecrypt(data, fileName);

加密

输入 project.json ,返回已加密的 sb3(Base64字符串):

import md5 from "tinyhmacmd5"

// 假设这是 project.json
const projectJson = JSON.stringify({})

// 生成新文件名(不含扩展名)。
// 逆向 vendor~main 可以看到用了 md5 。
// 你也可以直接用 Math.random() 随机生成 32 个字符的 hex :
//   let fileName = ""
//   while (fileName.length < 32) {
//     fileName += (0 | 16 * Math.random()).toString(16)
//   }
const fileName = md5('' + Date.now() + Math.random())

// 加密 project.json ,返回已加密的 sb3(Base64字符串)
const encryptedSb3 = await sb3Crypto.encrypt.encryptProjectJson(projectJson, fileName)

// sb3 字符串转字节数组
const encryptedSb3Bytes = new TextEncoder().encode(encryptedSb3)