admin管理员组文章数量:815041
如何从节点中的文件缓冲区创建十六进制
使用打字稿/节点/加密来创建哈希。
const fileBuffer = readFileSync(filePath);
const hashedFileName = crypto
.createHash("md5")
.update(fileBuffer)
.digest("hex");
但是得到一个...
Argument of type 'ArrayBuffer' is not assignable to parameter of type 'BinaryLike'.
Type 'ArrayBuffer' is missing the following properties from type 'Float64Array': BYTES_PER_ELEMENT, buffer, byteOffset, copyWithin, and 23 more.
有没有办法使这项工作有效?什么是BinaryLike?
回答如下:ArrayBuffer
不是.update
的有效参数,您必须将其转换为Buffer
或Uint8Array
const hashedFileName = crypto
.createHash("md5")
.update(Uint8Array.from(fileBuffer))
.digest("hex");
本文标签: 如何从节点中的文件缓冲区创建十六进制
版权声明:本文标题:如何从节点中的文件缓冲区创建十六进制 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/biancheng/1715189060a822166.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论