Example 1:the following Example uses AES function.
<Scripttype= "Text/javascript"src= "Http://cryptojs.altervista.org/api/functions_cryptography.js"></Script><Scripttype= "Text/javascript">varCrypt= NewCrypt (); //Constructor/** * Encrypt*/varCiphertext=Crypt.AES.encrypt ("plaintext");//XLUZVCUWZFU=3MD2VMZ8PHYSPJLKZIWJJG==1GV6N6TV8AZR/** * Decrypt*/varplaintext=Crypt.AES.decrypt (ciphertext);</Script>
Example 2:the following Example uses AES function with passphrase.
<Scripttype= "Text/javascript"src= "Http://cryptojs.altervista.org/api/functions_cryptography.js"></Script><Scripttype= "Text/javascript">varCrypt= NewCrypt (); //Constructor/** * Encrypt*/varCiphertext=Crypt.AES.encrypt ("plaintext", "Secret Passphrase");//H3fah9bppeg=xuhy8woetofyyi18tlm76a==bkuvkcztsnl8/** * Decrypt*/varplaintext=Crypt.AES.decrypt (Ciphertext,"Secret Passphrase");</Script>
Example 3:the following Example uses hash functions.
<Scripttype= "Text/javascript"src= "Http://cryptojs.altervista.org/api/functions_cryptography.js"></Script><Scripttype= "Text/javascript">varCrypt= NewCrypt (); //Constructor/** * MD5*/ varDIGEST_MD5=Crypt.HASH.md5 ("message"); //78e731027d8fd50ed642340b7c9a63b3/** * SHA1*/ varDIGEST_SHA1=CRYPT.HASH.SHA1 ("message"); //6f9b9af3cd6e8b8a73c2cdced37fe9f59226e27d/** * SHA224*/ vardigest_sha224=Crypt.HASH.sha224 ("message");//ff51ddfabb180148583ba6ac23483acd2d049e7c4fdba6a891419320/** * SHA256*/ vardigest_sha256=Crypt.HASH.sha256 ("message");//ab530a13e45914982b79f9b7e3fba994cfd1f3fb22f71cea1afbf02b460c6d1d/** * SHA384*/ vardigest_sha384=Crypt.HASH.sha384 ("message");//353eb7516a27ef92e96d1a319712d84b902eaa828819e53a8b09af7028103a9978ba8feb6161e33c3619c5da4c4666a5/** * SHA512*/ vardigest_sha512=Crypt.HASH.sha512 ("message");//f8daf57a3347cc4d6b9d575b31fe6077e2cb487f60a96233c08cb479dbf31538cc915ec6d48bdbaa96ddc1a16db4f4f96f37276cfcb3510b8246 241770D5952C</Script>
functions_cryptography.js Download:functions_cryptography.js
Cryptography-javascript Encryption Algorithm Library