23 lines
491 B
JavaScript
23 lines
491 B
JavaScript
const argon2 = require('argon2');
|
||
|
||
// argon2Test方法:接收一个字符串,返回其argon2哈希值
|
||
async function argon2Test(inputString) {
|
||
try {
|
||
// 使用默认配置生成argon2哈希
|
||
const hash = await argon2.hash(inputString);
|
||
return {
|
||
success: true,
|
||
hash: hash
|
||
};
|
||
} catch (error) {
|
||
console.error('argon2哈希计算失败:', error);
|
||
return {
|
||
success: false,
|
||
error: error.message
|
||
};
|
||
}
|
||
}
|
||
|
||
module.exports = {
|
||
argon2Test
|
||
}; |