标签:
JS加密代码如下
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/aes.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/pad-zeropadding.js"></script>
<script>
var data = "mysql_connect(‘111.111.111.111‘,‘root‘,‘111111‘)";
var key = CryptoJS.enc.Latin1.parse(‘1111111111111111‘);
var iv = CryptoJS.enc.Latin1.parse(‘1111111111111111‘);
var encrypted = CryptoJS.AES.encrypt(data, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.ZeroPadding });
document.write(encrypted);
</script>
PHP的解密代码如下
<?php
$privateKey = "1111111111111111";
$iv = "1111111111111111";
$encryptedData = base64_decode("JLbb3T6NekoYFIcLeRZ45g7uiP3ojMdgSSUk3VKZgSvWVcCqqr/GaIv0mQ/hMvht 5YCM87tC3c9t05izRtsbZg==");
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $encryptedData, MCRYPT_MODE_CBC, $iv);
echo($decrypted);
?>
个人学习留存
js加密的密文让PHP解密(AES算法)
标签:
原文地址:http://www.cnblogs.com/richerdyoung/p/4974005.html