Hash 为什么crypto.minute.digest返回空对象

Hash 为什么crypto.minute.digest返回空对象,hash,cryptography,webcrypto-api,Hash,Cryptography,Webcrypto Api,我有以下简单的代码: inputBytes=新的TextEncoder.encodeinputString hashBytes=await window.crypto.minute.digestSHA-256,inputBytes console.logtypeof hashBytes+:+JSON.stringifyhashBytes 为什么结果是空对象? 我怎样才能得到真正的结果 这太奇怪了,非常感谢你的帮助 返回使用包含摘要的ArrayBuffer实现的承诺 需要一个JavaScript对

我有以下简单的代码:

inputBytes=新的TextEncoder.encodeinputString hashBytes=await window.crypto.minute.digestSHA-256,inputBytes console.logtypeof hashBytes+:+JSON.stringifyhashBytes 为什么结果是空对象? 我怎样才能得到真正的结果

这太奇怪了,非常感谢你的帮助

返回使用包含摘要的ArrayBuffer实现的承诺

需要一个JavaScript对象。因此,必须相应地转换ArrayBuffer。一种可能是将缓冲区的内容转换为或编码的字符串,并在JavaScript对象中使用结果,例如

//发件人:https://stackoverflow.com/a/40031979/9014097 函数buf2hexbuffer{//buffer是一个ArrayBuffer 返回Array.prototype.map.callnew Uint8Arraybuffer,x=>'00'+x.toString16.slice-2.join; } //从https://stackoverflow.com/a/11562550/9014097 函数buf2Base64buffer{ 返回btoaString.fromCharCode.ApplyFull,新Uint8Arraybuffer; } 异步功能测试{ var inputString=敏捷的棕色狐狸跳过懒惰的狗; inputBytes=新的TextEncoder.encodeinputString; hashBytes=await window.crypto.minute.digestSHA-256,inputBytes; stringify{hash:buf2hexhashBytes};/{hash:d7a8fbb307d7809469ca9abcb082e4f8d5651e46d3cdb762d02d0bf37c9e592} stringify{hash:buf2Base64hashBytes};/{hash:16j7swfxgjjrpypq8sagut41wuertpnt2lqlqlvzfj5zi=} } 试验 返回使用包含摘要的ArrayBuffer实现的承诺

需要一个JavaScript对象。因此,必须相应地转换ArrayBuffer。一种可能是将缓冲区的内容转换为或编码的字符串,并在JavaScript对象中使用结果,例如

//发件人:https://stackoverflow.com/a/40031979/9014097 函数buf2hexbuffer{//buffer是一个ArrayBuffer 返回Array.prototype.map.callnew Uint8Arraybuffer,x=>'00'+x.toString16.slice-2.join; } //从https://stackoverflow.com/a/11562550/9014097 函数buf2Base64buffer{ 返回btoaString.fromCharCode.ApplyFull,新Uint8Arraybuffer; } 异步功能测试{ var inputString=敏捷的棕色狐狸跳过懒惰的狗; inputBytes=新的TextEncoder.encodeinputString; hashBytes=await window.crypto.minute.digestSHA-256,inputBytes; stringify{hash:buf2hexhashBytes};/{hash:d7a8fbb307d7809469ca9abcb082e4f8d5651e46d3cdb762d02d0bf37c9e592} stringify{hash:buf2Base64hashBytes};/{hash:16j7swfxgjjrpypq8sagut41wuertpnt2lqlqlvzfj5zi=} } 测验