@chikawa222224 / testchikawa222224_2
绑定的Node.js散列库 _chikawa222224_testchikawa222224_2.bin 二进制文件。
哈希计算
标准库按顺序计算这些字节的哈希值:
- 完整的捆绑文件字节。
- 从Base64参数解码的二进制附件。
换句话说: hash(fileBytes + Base64Decode(base64Attachment)).
默认算法为SHA-256,结果以小写十六进制字符串返回。
使用
const { calculateHash } = require("@chikawa222224/testchikawa222224_2");
const attachmentBase64 = Buffer.from("attachment bytes").toString("base64");
calculateHash(attachmentBase64).then(console.log);
省略附件,只计算绑定的文件哈希值:
calculateHash().then(console.log);
使用Node.js支持的另一种算法:
calculateHash(attachmentBase64, "sha512").then(console.log);
API
calculateHash(base64Attachment = "", algorithm = "sha256")
返回一个 Promise<string> 包含计算的哈希值。无效的Base64输入或不支持的算法拒绝承诺。
binaryPath
包含绑定的二进制文件的绝对路径。