This article mainly introduces how to solve the garbled code problem after PHPaes (ecb) is decrypted. It is very simple and practical. If you need it, you can refer to it. Content: abcd
KEY: 1234567890123456.
Encrypted base64: T7UT2NQ1AFvR9unjA0wKWA =
function apiDataDecrypt($data, $key='') { $data = base64_decode($data); $pad = 16 - (strlen($data) % 16); $padData = $data . str_repeat(chr($pad), $pad); return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key,$padData, MCRYPT_MODE_ECB);} }
Directly attach the solution
$key = '1234567890123456';$content = 'T7UT2NQ1AFvR9unjA0wKWA==';$desStr = decryptString($content,$key);echo($desStr);function decryptString($str,$key) { $str = base64_decode($str); $str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $str, MCRYPT_MODE_ECB); $block = mcrypt_get_block_size('rijndael_128', 'ecb'); $pad = ord($str[($len = strlen($str)) - 1]); $len = strlen($str); $pad = ord($str[$len-1]); return substr($str, 0, strlen($str) - $pad);}
The above is all the content of this article. I hope you will like it.