crypto -js加密 javascript
<script type="text/javascript" src="http://vod11.gzsg.net.cn/demo/extend/js/crypto-js/rollups/aes.js" charset="utf-8"></script> <script type="text/javascript"> CryptoJS.pad.ZeroPadding = { pad: function(data, blockSize) { var blockSizeBytes = blockSize * 4; data.clamp(); data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes) }, unpad: function(data) { var dataWords = data.words; var i = data.sigBytes - 1; while (! ((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) { i-- } data.sigBytes = i + 1 } }; var get = function(str) { var key_hash = CryptoJS.MD5("7648121057646619"); var key = CryptoJS.enc.Utf8.parse(key_hash); var iv = CryptoJS.enc.Utf8.parse("0053739753593058"); var encrypted = CryptoJS.AES.encrypt(str, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.ZeroPadding }); return encrypted.toString() } var data = get("e2b2lSopbtlm2UmeYajJ6LzsZdWI3EaG9VcalL/8MO5yj+PMuKpnaB0ulpqbIj/Im6DL+S0R93N5ntfEBuQ6DZuLKGS0IFl2CioSXiDPf7/92Q") console.log(data); </script>
php解密/加密php
$data = 'b6683KhhiROhOUX1Qi7dxW+QcTv92/H+kBiOx8rMuWJ3XMgn42KAHDBUdbWMeDfOGGLjAqpqVvCWqgiF/DH7w/XlnoFNKVxv0ns9fcBZFdWsBI9H1pdfTQ'; $key = md5('7648121057646619'); //CuPlayer.com提示key的長度必須16,32位,這裏直接MD5一個長度爲32位的key $iv='0053739753593058'; $crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv); $decode = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $crypttext, MCRYPT_MODE_CBC, $iv);/*原始數據*/ $data= base64_encode($crypttext);/*加密加的數據*/