This article mainly introduces the PHP AES (ECB) decryption problem after the solution, very simple and practical, the need for small partners can refer to.
Content: ABCD
key:1234567890123456
base64:t7ut2nq1afvr9unja0wkwa== after encryption
?
1 2 3 4 5 6 7 |
function Apidatadecrypt ($data, $key = ') {$data = Base64_decode ($data); $pad =-(strlen ($data); $padData = $data . Str_repeat (Chr ($pad), $pad); Return Mcrypt_decrypt (mcrypt_rijndael_128, $key, $padData, MCRYPT_MODE_ECB); } } |
Just attach the solution.
?
1 2 3 4 5 6 7 8 9 10 11 12 13-14 |
$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, MC RYPT_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 mentioned is the entire content of this article, I hope you can enjoy.