<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>aesCbc</title> <script type="text/javascript" src="crypto-js.min.js"></script> <script type="text/javascript">
//直接上代码 var key = CryptoJS.enc.Utf8.parse('1234567890123456');
var iv = CryptoJS.enc.Utf8.parse('1234560123456789');
var password=CryptoJS.enc.Utf8.parse('要加密的字符串'); var encrypted = CryptoJS.AES.encrypt(password, key, { iv: iv,mode:CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7}); //CryptoJS.pad.ZeroPadding console.log("base64:"+encrypted);
var encryptedStr=encrypted.ciphertext.toString();
console.log("16进制:"+encryptedStr); //OCgklXdtTX/J9rsC2OHL+X/E7XoedVl2DBVzNiUUWU0=
//OCgklXdtTX/J9rsC2OHL+X/E7XoedVl2DBVzNiUUWU0= </script> </html>