CryptoJS

Cryptographic and hashing functions are provided by the CryptoJS library. It provides encryption algorithms such as AES and DES, hashing functions such as MD5, SHA1 and SHA256, signing algorithms such as HMAC, and more. You can read the full documentation for our version here.

The library is available through the global CryptoJS variable. For example, in order to get the SHA1 hash of a message, you can use: var hash = CryptoJS.SHA1("message").toString();

// CryptoJS examples
var a = CryptoJS.AES.encrypt("my message", "secret key 123");
a = CryptoJS.AES.decrypt(a, "secret key 123").toString(CryptoJS.enc.Utf8);
console.log("a = " + a);

var b = CryptoJS.MD5("message");
console.log("b = " + b);

var c = CryptoJS.SHA1("message");
console.log("c = " + c);

var d = CryptoJS.SHA256("message").toString(CryptoJS.enc.Base64);
console.log("d = " + d);

var e = CryptoJS.HmacMD5("message", "passphrase");
console.log("e = " + e);