/*
* Crypto
*/
var crypto = require('crypto');
var content = 'password';//
/*
*
* var hash = crypto.createHash(algorithm); // algorithm: 'md5', 'sha1', 'sha256', 'sha512', 'ripemd160'
* hash.update(content,[input_encoding]); // ,input_encoding:'utf8'
* var dig = digest([encoding)];// ,encoding: 'hex','base64', hash
*/
/*
* ,
*/
// md5: , 16
var md5 = crypto.createHash('md5');
md5.update(content);
var md5dig = md5.digest('hex');
console.log(md5dig);// :5f4dcc3b5aa765d61d8327deb882cf99
// sha1: , 20 。
var shasum = crypto.createHash('sha1');
shasum.update(content);
var shadig = shasum.digest('hex');
console.log(shadig);// :5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8
/*
* ,
*/
// Hmac :HMAC , ,
var secrectKey = 'secrectKey';//
var hmac = crypto.createHmac('sha1', secrectKey);
hmac.update(content);
var hmacdig = hmac.digest('hex');
console.log(hmacdig);// :c56952b778fc09059b9ece64a458323822f77aed