| Crates.io | hbsx |
| lib.rs | hbsx |
| version | 0.2.9 |
| created_at | 2025-12-10 09:41:58.737421+00 |
| updated_at | 2025-12-11 03:09:12.520707+00 |
| description | A easy-to-use file encryption tool with compression support |
| homepage | https://github.com/jihuayu/xor |
| repository | https://github.com/jihuayu/xor |
| max_upload_size | |
| id | 1977751 |
| size | 178,579 |
# 全局安装
npm install -g @jihuayu/hbsx
# 使用 npx(无需安装)
npx @jihuayu/hbsx [options]
支持的平台:
# 克隆仓库
git clone https://github.com/jihuayu/xor.git
cd xor
# 编译
cargo build --release
# 运行
./target/release/xor
数据库文件自动存储在用户主目录:
C:\Users\<用户名>\.xor\data.db~/.xor/data.db存储文件处理记录:
id: 主键relative_path: 文件相对路径(唯一)modified_time: 文件修改时间original_hash: 原始文件 SHA256 哈希output_hash: 输出文件 SHA256 哈希created_at: 首次处理时间updated_at: 最后更新时间存储处理日志:
id: 主键file_path: 文件路径action: 操作类型(check, process)status: 状态(new, changed, skip, success, failed, error)message: 日志消息timestamp: 时间戳程序会智能检测文件变化:
检查修改时间:
检查文件哈希:
处理状态标识:
✅ 新增: - 首次处理的文件🔄 更新: - 重新处理的已存在文件# 使用默认参数
cargo run
# 指定输入目录、输出目录和密码
cargo run -- <输入目录> <输出目录> <密码>
# 处理 ./input 目录下的文件,输出到 ./output
cargo run
# 处理指定目录
cargo run -- /path/to/input /path/to/output mypassword
# Release 模式(更快)
cargo build --release
./target/release/xor /path/to/input /path/to/output mypassword
程序运行时会显示:
📁 输入目录: ./input
📁 输出目录: ./output
🔐 密码已设置
💾 数据库位置: C:\Users\username\.xor\data.db
🚀 使用 Rayon 多线程 + Zstd 多线程压缩 + SIMD 加速哈希
📊 找到 10 个文件
✅ 新增: file1.txt
✅ 新增: file2.jpg
🔄 更新: file3.pdf
📋 清单已生成: ./output/manifest.csv
🎉 所有文件处理完成!共 3 个文件
加密文件:
.zstd.encCSV 清单:
manifest.csv 文件记录所有处理的文件信息数据库文件:
~/.xor/data.db 存储完整的文件记录和处理日志opt-level = 3: 最高优化级别lto = true: 链接时优化codegen-units = 1: 单一代码生成单元,更好的优化输出文件采用自定义容器格式:
[MAGIC: 4字节 "ZENC"]
[VERSION: 1字节]
[SALT_LEN: 1字节]
[SALT: 16字节]
[NONCE_LEN: 1字节]
[NONCE: 12字节]
[CIPHERTEXT: 变长]
walkdir: 递归遍历目录zstd: Zstandard 压缩算法(多线程支持)aes-gcm: AES-256-GCM 加密rand: 随机数生成pbkdf2: PBKDF2 密钥派生sha2: SHA256 哈希(SIMD 加速)anyhow: 错误处理csv: CSV 文件生成chrono: 时间处理rayon: 并行处理rusqlite: SQLite 数据库dirs: 用户目录获取~/.xor 目录和数据库文件可以使用 SQLite 命令行工具查询数据库:
# 查看所有文件记录
sqlite3 ~/.xor/data.db "SELECT * FROM files;"
# 查看最近的日志
sqlite3 ~/.xor/data.db "SELECT * FROM logs ORDER BY timestamp DESC LIMIT 10;"
# 查看处理失败的文件
sqlite3 ~/.xor/data.db "SELECT * FROM logs WHERE status = 'failed' OR status = 'error';"
# 统计处理的文件数量
sqlite3 ~/.xor/data.db "SELECT COUNT(*) FROM files;"
MIT