|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-05-15 16:37 UTC] levim@php.net
[2014-05-15 21:13 UTC] nikic@php.net
-Status: Open
+Status: Wont fix
[2014-05-15 21:13 UTC] nikic@php.net
[2014-09-23 22:51 UTC] dharkness at gmail dot com
[2014-10-15 18:36 UTC] gm dot outside+php at gmail dot com
[2016-05-18 08:31 UTC] wcode404 at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 15:00:02 2025 UTC |
Description: ------------ php version <= 5.5.12 string(6) "zxcvbn" Warning: mcrypt_encrypt(): Key of size 32 not supported by this algorithm. in /test.php on line 9 Warning: mcrypt_decrypt(): Key of size 32 not supported by this algorithm. in /test.php on line 17 string(0) "zxcvbn" php version >= 5.6 string(6) "zxcvbn" Warning: mcrypt_encrypt(): Key of size 32 not supported by this algorithm. Only keys of size 24 supported in /test.php on line 9 Warning: mcrypt_decrypt(): Key of size 32 not supported by this algorithm. Only keys of size 24 supported in /test.php on line 17 string(0) "" ================ I know this warning is good thing 。 If you are upgrading php 5.5 to 5.6 , the php program does not work 。This maybe a serious problem。 Test script: --------------- <?php function encrypt($data, $key) { $block = mcrypt_get_block_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB); $pad = $block - (strlen($data) % $block); $data .= str_repeat(chr($pad), $pad); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB), MCRYPT_RAND); $encrypted = mcrypt_encrypt(MCRYPT_TRIPLEDES, $key, $data, MCRYPT_MODE_ECB, $iv); return $encrypted; } function decrypt($data, $key) { $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB), MCRYPT_RAND); $data = mcrypt_decrypt(MCRYPT_TRIPLEDES, $key, $data, MCRYPT_MODE_ECB, $iv); $block = mcrypt_get_block_size(MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB); $pad = ord($data[($len = strlen($data)) - 1]); $decrypted = substr($data, 0, strlen($data) - $pad); return rtrim($decrypted); } $key = md5('asdfgh'); $original_data = 'zxcvbn'; var_dump($original_data); $data = encrypt($original_data, $key); $data = base64_encode($data); $data = base64_decode($data); $data = decrypt($data, $key); var_dump($data); Expected result: ---------------- string(6) "zxcvbn" Warning: mcrypt_encrypt(): Key of size 32 not supported by this algorithm. Only keys of size 24 supported in /test.php on line 9 Warning: mcrypt_decrypt(): Key of size 32 not supported by this algorithm. Only keys of size 24 supported in /test.php on line 17 string(0) "zxcvbn" Actual result: -------------- string(6) "zxcvbn" Warning: mcrypt_encrypt(): Key of size 32 not supported by this algorithm. Only keys of size 24 supported in /test.php on line 9 Warning: mcrypt_decrypt(): Key of size 32 not supported by this algorithm. Only keys of size 24 supported in /test.php on line 17 string(0) ""