crypto-js可用於加密。簡單加密可直接以下使用:git
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/github