我正在编写一个需要密码哈希的网络应用程序。我正在使用argon2
来自 npm 的包来实现这一点。
下面是我编写的一个函数,它返回一个字符串,$argon2i$v=19$m=4096,t=3,p=1$QC3esXU28vknfnOGCjIIaA$f/2PjTMgmqP1nJhK9xT0bThniCEk28vX2eY6NdqrLP8
但是Promise { <pending> }
当值为 console.log(ed) 时函数返回。
代码是:
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> }
有人可以帮我解决这个问题吗?
非常感谢。