digest
Promise<String>
该代码居住在我的
export default async function hashPassword(unHashedPassword) {
return crypto.subtle.digest('SHA-256', unHashedPassword)
.then((hash) => _arrayBufferToBase64(hash))
}
function _arrayBufferToBase64( buffer ) {
let binary = '';
const bytes = new Uint8Array( buffer );
const len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
return btoa( binary );
}
app的文件夹中的一个名为
hasher.js
文件中的文件中。
然后,该函数被用来放置用户输入形式的各种数据。我这样用它:
libs
,但是,当代码的这一部分运行时,我会收到以下错误:
NextJS
我试图修复它的方法:首先,我认为也许图书馆丢失了。我可以确认这是不正确的,因为它是由IDE索引的。
next,我查找了这个,发现const licenseKey = formData.get('licenseKey')
const hashedPasswordPromise = hashPassword(licenseKey)
hashedPasswordPromise.then(hashedPassword => {
console.log("Hashed License:", hashedPassword)
})
模块只能在一个Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'digest')
crypto
)。因此,我将使用SSL设置
SecureContext
以将请求反向代理到http
nginx
next
next,我考虑了启动
https
启动keychain
启动。我唯一能找到的结果是我所做的next
https
或使用nginx
,这仅在--experimental-https
而不是生产中可用,这是不好的。
我很难过。关于如何解决此问题的任何建议?指出
dev
实际上是subtle
。
i用此代码替换了我的功能,现在可以工作(并且更好,因为它只是返回a
undefined
而不是a
string
::
Promise<String>