Node.js 如何在NodeJS中使用SHA256
如何在Node.js中将字符串简单地转换为SHA256字符串。 并将SHA256字符串转换为普通字符串Node.js 如何在NodeJS中使用SHA256,node.js,sha256,Node.js,Sha256,如何在Node.js中将字符串简单地转换为SHA256字符串。 并将SHA256字符串转换为普通字符串 const shajs = require('sha.js'); console.log('starts'); const code = 'WEASDSAEWEWAEAWEAWEWA'; const normal = 'anne'; const encrypted = shajs('sha256') .update(normal) .digest('hex'); cons
const shajs = require('sha.js');
console.log('starts');
const code = 'WEASDSAEWEWAEAWEAWEWA';
const normal = 'anne';
const encrypted = shajs('sha256')
.update(normal)
.digest('hex');
const unencrypted = shajs('sha256')
.read(normal)
.toString('hex');
console.log(normal);
console.log(encrypted);
console.log(unencrypted);
console.log('end');
哈希代码应该放在哪里?SHA256是一个单向哈希函数,这意味着您只能将字符串转换为哈希值,而不能将其反向转换。要检查密码,您需要重新设置普通密码,并将其和数据库中已存储的密码进行比较 你说的散列码是什么意思?你知道SHA256是单向散列吗?无法将其转换回普通字符串。另外,在node.js中,查看哪个是内置的。在我使用的另一种语言SHA256中,我创建了一个哈希代码来转换密码#define HASH_CODE='weasdssaewawaweaweawa';SHA256_PassHash(输入文本,哈希代码,密码,64);