Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何在NodeJS中使用SHA256_Node.js_Sha256 - Fatal编程技术网

Node.js 如何在NodeJS中使用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

如何在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');
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);