html代码
<html> <head> <title>Crypto</title> </head> <body> <div> This is the encrypted version of the plain text - <span id="encrypted text"></span> </div> <div> This is the decrypted version of the plain text - <span id="decrypted text"></span> </div> <div> This is when we enter a wrong pass key - <span id="wrong key"></span> </div> <script type="text/javascript" src="http://cryptojs.altervista.org/api/functions_cryptography.js"></script> <script type="text/javascript"> var Crypt = new Crypt(); // constructor /*** encrypt */ var ciphertext = Crypt.AES.encrypt("Hello, my name's Bob", "Bob"); // XluzvcUwZFU=3MD2vMz8PHySPJlKZiWjJg==1Gv6n6Tv8azr /*** decrypt */ var plaintext = Crypt.AES.decrypt(ciphertext, "Bob"); var wrongkey = Crypt.AES.decrypt(ciphertext, "Bob") document.getElementById("encrypted text").innerHTML = ciphertext; document.getElementById("decrypted text").innerHTML = plaintext; document.getElementById("wrong key").innerHTML = wrongkey; </script> </body>
http://cryptojs.altervista.org/api/functions_cryptography.js 建议下载下来引用,,远程引用速度有影响