10. crypto加密
(1) 加密方式
Hash包括md5算法、sha1算法、sha256算法、sha512算法等
AES对称加密
Diffie-Hellman密钥交换协议
(2) Hash
Crypto.createHash() --加密方法
Hash.update --加密的密码
Hash.digest --编码
// 导入模块
const crypto = require('crypto');
const md5 = require('md5');
// md5的hash加密
const hash = crypto.createHash('md5');
hash.update('123456');
let hashCode = hash.digest('hex');
console.log(hashCode);
console.log(hashCode.length);
console.log('md5加密:'+md5('123456'));