Switch branches/tags
Nothing to show
Find file Copy path
e7cefd7 Feb 8, 2017
1 contributor

Users who have contributed to this file

63 lines (56 sloc) 1.82 KB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="jquery1.4.js"></script>
<script type="text/javascript" src="crypto-js.js"></script>
<script type="text/javascript" src="jquery.base64.min.js"></script>
<script type="text/javascript">
var key = CryptoJS.enc.Utf8.parse("1486538739931000");
* [encrypt 加密]
* @return {[type]} [description]
function encrypt() {
var content = $("#encryptContent").val();
console.log("content", content)
var encryptResult = CryptoJS.AES.encrypt(content, key, {
iv: key,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
* [decrypt 解密]
* @return {[type]} [description]
function decrypt() {
var content = $("#decryptContent").val();
var bytes = CryptoJS.AES.decrypt(content.toString(), key, {
iv: key,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
var decryptResult = bytes.toString(CryptoJS.enc.Utf8);
<input type="text" id="encryptContent" />
<input type="button" value="AES加密" onclick="encrypt()" /> 加密结果:
<input type="text" id="encryptResult" />
<br/> 解密文本:
<input type="text" id="decryptContent" />
<input type="button" value="AES解密" onclick="decrypt()" /> 解密结果:
<input type="text" id="decryptResult" />