npm install crypto-js

发布于 2014-05-22  约 2 分钟

crypto-js可用于加密。简单加密可直接如下使用:


var CryptoJS = require('crypto-js');
var hash = CryptoJS.MD5('celavie');
console.log(hash.toString());
console.log('md5 base64: ' + hash.toString(CryptoJS.enc.Base64));

var hash = CryptoJS.SHA1('celavie');
console.log(hash.toString());
console.log('sha1 base64: ' + hash.toString(CryptoJS.enc.Base64));

var hash = CryptoJS.SHA256('celavie');
console.log(hash.toString());
console.log('sha256 base64: ' + hash.toString(CryptoJS.enc.Base64));

var hash = CryptoJS.SHA512('celavie');
console.log(hash.toString());
console.log('sha512 base64: ' + hash.toString(CryptoJS.enc.Base64));

var hash = CryptoJS.SHA3('celavie');
console.log(hash.toString());
console.log('sha3 base64: ' + hash.toString(CryptoJS.enc.Base64));

详细用法参照:https://code.google.com/p/crypto-js/

阅读 4.5k发布于 2014-05-22

推荐阅读
orz71
用户专栏

0 人关注
6 篇文章
专栏主页
目录