RClone 密码
在TypeScript/JavaScript中执行RClone Crypt算法子集.
这基本上是一些逐行翻译 rclone/backend/crypt/cipher.go 财务报告和审定财务报表 rclone/backend/crypt/cipher_test.go,特征有限.
为什么
因为我希望使用广泛使用的Rclone格式在TypeScript/JavaScript加密文件.
使用量
npm install @fyears/rclone-crypt
import { Cipher } from "@fyears/rclone-crypt";
import { deepStrictEqual } from "assert";
(async function () {
const password = "custom-password";
const salt = "custom-salt";
const cipher = new Cipher("base32");
await cipher.key(password, salt);
const fileName = "custom-dir/custom-filename";
const encFileName = await cipher.encryptFileName(fileName);
console.log(encFileName);
const recoveredFileName = await cipher.decryptFileName(encFileName);
console.log(recoveredFileName);
deepStrictEqual(fileName, recoveredFileName);
const fileContent = new Uint8Array([1, 2, 3, 4, 5]); // user provided
const encFileContent = await cipher.encryptData(fileContent);
console.log(encFileContent);
const recoveredFileContent = await cipher.decryptData(encFileContent);
console.log(recoveredFileContent);
deepStrictEqual(fileContent, recoveredFileContent);
})();
特征
- 文件名加密/解密
- 文件内容加密
- 许多测试
- 流媒体加密/解密
文件名模糊( 未规划)