首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用回调值调用value函数

使用回调值调用value函数
EN

Stack Overflow用户
提问于 2017-11-15 03:33:25
回答 1查看 166关注 0票数 0

我尝试将密码散列并存储到数据库中。因此,我在node应用程序中使用了带有crypto_pwhash的libsodium。我创建了一个函数,将其导出,但我无法收到散列密码。

下面是我的代码: sodium.js

代码语言:javascript
运行
复制
libsodium = require('libsodium-wrappers-sumo');
 (async() => {
await libsodium.ready;
const sodium = libsodium;

module.exports.password_hash = function(password, res){
var hashed_password = [sodium.crypto_pwhash_STRBYTES];
 if (sodium.crypto_pwhash_str ( sodium.crypto_pwhash_MEMLIMIT_SENSITIVE) != 0){
   /* out of memory */
}
   return res(hashed_password);
}
/*if (sodium.crypto_pwhash_str_verify
(hashed_password, PASSWORD, strlen(PASSWORD)) != 0) {
/* wrong password */
//}
})();

app.js

代码语言:javascript
运行
复制
sodium.password_hash("test", function(res){
        console.log(res);  
     });

错误消息是:密码输入类型不受支持。

我不明白出了什么问题

更新:我更新了我的代码,现在错误消息是:当定义时,输出格式必须是一个字符串,我认为这是数组的问题

EN

回答 1

Stack Overflow用户

发布于 2017-11-20 20:54:43

sodium.crypto_pwhash_str将散列密码返回到字符串中,不需要第一个参数

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47293862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档