Maison >développement back-end >tutoriel php >CryptoJS加密此中iv为32位,php 解密
CryptoJS加密其中iv为32位,php 解密
<br /><script type="text/javascript" src='aes.js'></script><br /> <script type="text/javascript"><br /> var key = '123454536f667445454d537973576562';<br /> key = CryptoJS.enc.Hex.parse(key);<br /> var iv = CryptoJS.enc.Hex.parse("1234577290ABCDEF1264147890ACAE45");<br /> var encrypted = CryptoJS.AES.encrypt('T10515', key, {iv: iv,mode:CryptoJS.mode.CBC}).toString()<br /> alert(encrypted);<br /> </script><br />
<br /><?php<br />$pk = "123454536f667445454d537973576562";<br />$iv = "1234577290ABCDEF1264147890ACAE45";<br />$t = ('T10515');<br /><br />$encrypted = ( mcrypt_encrypt(MCRYPT_RIJNDAEL_128,$pk,$t,MCRYPT_MODE_CBC,$iv) );<br />echo 'base64_encode'.(base64_encode($encrypted)).'<br>';<br />?><br />
<br />Warning: mcrypt_encrypt(): Received initialization vector of size 32, but size 16 is required for this encryption mode in F:\LAMP\Apache2.4\htdocs\fee\cry.php on line 32<br />