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); ?> |
參考了這位博友的文章
http://www.cnblogs.com/AloneSword/p/3485912.html
這位博友的博文甚至可以搞定JAVA和C#版本的
贊一個!