当前位置:Gxlcms >
数据库问题 >
[Web Security] Create a hash salt password which can stored in DB
[Web Security] Create a hash salt password which can stored in DB
时间:2021-07-01 10:21:17
帮助过:10人阅读
crypto = require(
‘crypto‘);
var password =
"monkey";
// randomBytes: generate a salt pre user, salt should be stored with hashed password in the database
crypto.randomBytes(
256, function(err, salt) {
// pbkdf2: combine the salt the hash password algorithm, to generate a safe password
crypto.pbkdf2(password, salt,
100000,
512,
‘sha256‘,
function(err, hash) {
console.log("The result of hashing " + password +
" is:\n\n" +
hash.toString(‘hex‘) +
"\n\n");
});
});
[Web Security] Create a hash salt password which can stored in DB
标签:this and base SHA256 cti anti har for com