【发布时间】:2020-09-04 11:29:13
【问题描述】:
我正在编写一个需要密码哈希的网络应用程序。我正在使用来自 npm 的 argon2 包来实现这一点。
下面是我编写的一个函数,它返回一个字符串,例如$argon2i$v=19$m=4096,t=3,p=1$QC3esXU28vknfnOGCjIIaA$f/2PjTMgmqP1nJhK9xT0bThniCEk28vX2eY6NdqrLP8,但当值为console.log(ed)时,该函数返回Promise { <pending> }。
代码是:
async function hashPassword(password) {
try {
const hash = await argon2.hash(password);
return hash;
} catch {
console.log('Error');
}
}
const hashedPassword = hashPassword('password');
console.log(hashedPassword);
所以,console.log() 的输出是 Promise { <pending> }
有人可以帮我解决这个问题吗?
非常感谢。
【问题讨论】:
标签: node.js npm argon2-ffi