Should I Trim the Decrypted String after mcrypt_decrypt?

后端 未结 4 746
一整个雨季
一整个雨季 2021-02-07 20:40

I have a code that goes something like:

$cipher_alg = MCRYPT_RIJNDAEL_128;
$decrypted_string = mcrypt_decrypt($cipher_alg, $key, 
$encrypted_string , MCRYPT_MODE         


        
4条回答
  •  一整个雨季
    2021-02-07 20:51

    After 24 hours of research, finally this worked for me:

    function removePadding($decryptedText){
        $strPad = ord($decryptedText[strlen($decryptedText)-1]);
        $decryptedText= substr($decryptedText, 0, -$strPad);
        return $decryptedText;
    }
    

提交回复
热议问题