标签:分享 string res ret tran nod img oms func
demo
var crypto = require(‘crypto‘); function getRandomSalt(){ return Math.random().toString().slice(2, 5); } function cryptPwd(password, salt) { // 密码“加盐” var saltPassword = password + ‘:‘ + salt; console.log(‘原始密码:%s‘, password); console.log(‘加盐后的密码:%s‘, saltPassword); // 加盐密码的md5值 var md5 = crypto.createHash(‘md5‘); var result = md5.update(saltPassword).digest(‘hex‘); console.log(‘加盐密码的md5值:%s‘, result); } var password = ‘123456‘; var salt=‘abc‘; cryptPwd(password, getRandomSalt()); cryptPwd(password, getRandomSalt()); cryptPwd(password,‘abc‘);
输出:
2017-10-30
标签:分享 string res ret tran nod img oms func
原文地址:http://www.cnblogs.com/guangzhou11/p/7753433.html