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

@roson_liu/encrypt-tool

v0.8.0

Published

Cross-platform CLI encryption tool for files, directories, text, and RSA helper workflows

Readme

Encrypt Tool

跨平台 Node.js 命令行加密工具,支持文件、目录、文本和 RSA 辅助加解密。

特性

  • 文件加密与解密,输出单个 .enc 容器文件。
  • 目录加密支持 archiveper-file 两种模式。
  • 文本加密适合命令管道和少量文本内容。
  • RSA 辅助命令支持生成密钥、小内容加密和解密。
  • 使用 AES-256-GCM 认证加密和 scrypt 密码派生。
  • 加密容器不会在公开 header 中暴露原始文件名、目录结构、文件大小或时间戳。
  • 支持中文和英文提示。
  • 支持通过命令安装和卸载 PowerShell Tab 补全。

安装

npm install -g @roson_liu/encrypt-tool

本地开发时可以先安装依赖并构建:

npm install
npm run build
node dist/cli.js --help

Shell 补全

PowerShell 用户可以执行:

encrypt-tool completion install powershell

重新打开终端后,可以使用 Tab 补全命令和选项:

encrypt-tool <Tab>
encrypt-tool enc --<Tab>
encrypt-tool rsa <Tab>

如需移除 PowerShell 补全:

encrypt-tool completion uninstall powershell

文件加密

encrypt-tool enc ./a.txt
encrypt-tool dec ./a.txt.enc

自动化场景建议使用密码文件:

encrypt-tool enc ./a.txt --password-file ./password.txt -o ./a.txt.enc
encrypt-tool dec ./a.txt.enc --password-file ./password.txt -o ./a.txt

工具默认不支持 --password <value>,避免密码进入 shell 历史记录。

目录加密

archive 模式会把目录打包为 tar.gz 流,再写入单个 .enc 容器:

encrypt-tool enc ./docs --mode archive
encrypt-tool dec ./docs.enc

per-file 模式会为每个目录或文件写入独立的加密 entry metadata record,文件内容按 entry 独立分块:

encrypt-tool enc ./docs --mode per-file
encrypt-tool dec ./docs.enc

两种模式最终都会输出一个 .enc 文件。

文本加密

echo "hello" | encrypt-tool text enc
echo "<ciphertext>" | encrypt-tool text dec

摘要/哈希

摘要命令用于计算文件、文本或标准输入的哈希值,不需要密码,也不会生成加密容器。

encrypt-tool hash ./a.txt
encrypt-tool hash --text "hello" --alg sha512
echo "hello" | encrypt-tool digest --encoding base64

没有传入文件、--text 或标准输入时,交互式终端会提示输入文本;非交互环境会报缺少输入,避免脚本挂起。

常用选项:

| 选项 | 说明 | | --- | --- | | -a, --alg <algorithm> | 摘要算法,默认 sha256 | | --algorithm <algorithm> | 摘要算法,等同于 --alg | | -e, --encoding <encoding> | 输出编码,默认 hex | | -t, --text <value> | 直接计算字面文本 |

支持的算法:

| 算法 | 说明 | | --- | --- | | md5 | 兼容旧系统,不建议用于安全校验 | | sha1 | 兼容旧系统,不建议用于安全校验 | | sha224 | SHA-2 系列 | | sha256 | 默认算法,通用推荐 | | sha384 | SHA-2 系列 | | sha512 | SHA-2 系列 | | blake2b512 | BLAKE2b 512 位摘要 | | blake2s256 | BLAKE2s 256 位摘要 |

支持的输出编码:

| 编码 | 说明 | | --- | --- | | hex | 十六进制,默认格式,适合校验值展示 | | base64 | 标准 Base64,适合和传统工具互通 | | base64url | URL 安全 Base64,适合放入 URL、文件名或 token |

RSA 辅助命令

encrypt-tool rsa gen -o ./keys
encrypt-tool rsa enc "hello" --key ./keys/public.pem
encrypt-tool rsa dec "<base64-ciphertext>" --key ./keys/private.pem

--key 接受公钥或私钥文件,工具会自动识别密钥类型。

也支持私钥加密、公钥解密的辅助方向:

encrypt-tool rsa enc "hello" --key ./keys/private.pem
encrypt-tool rsa dec "<base64-ciphertext>" --key ./keys/public.pem

RSA 只适合小内容。公钥加密方向使用 RSA-OAEP-SHA256;私钥加密方向使用 RSA-PKCS#1 v1.5。

查看公开信息

encrypt-tool info ./docs.enc

info 只读取公开 header,不需要密码,不显示原始文件名、目录结构、文件大小或时间戳。

常用选项

| 选项 | 说明 | | --- | --- | | -o, --out <path> | 指定输出路径 | | --password-file <path> | 从文件读取密码 | | -f, --force | 覆盖已有输出 | | -y, --yes | 跳过非破坏性确认 | | --no-progress | 禁用进度条 | | --lang <locale> | 指定语言,例如 zh-CNen-US |

安全说明

  • 请使用足够强的密码;弱密码无法通过算法本身弥补。
  • 密码文件应妥善保护,避免提交到版本库。
  • .enc 容器的公开 header 会包含格式版本、算法、KDF 参数、salt、chunk size 等必要公开信息。
  • 文件名、目录结构、文件大小、mtime、权限等敏感元数据保存在加密 record 中。
  • 解密失败统一提示为密码错误或文件损坏,避免泄露内部判断细节。

格式兼容

容器格式使用独立版本号。当前容器版本为 1

后续如果修改 record 布局、AAD、manifest、entry metadata、footer 或 nonce 规则,应升级容器格式版本,并保留旧版本读取能力。

发布

npm login
npm publish

发布前会执行:

npm run build
npm test