I have a code that goes something like:
$cipher_alg = MCRYPT_RIJNDAEL_128;
$decrypted_string = mcrypt_decrypt($cipher_alg, $key,
$encrypted_string , MCRYPT_MODE_CBC, trim(hex2bin(trim($hexiv))));
I worry that in the process of decoding the mcrypt_decrypt
will introduce a gratuitous whitespace or null characters at the back or front of the $decrypted_string
.
So should I trim it?
Note: I could have run the code and find this out. But since I can never run enough samples to prove ( or disprove) my point, I want some concrete and theoretical answers, probably based on the inner working of the mcrypt_decrypt
algorithm. Another reason I ask is that I believe this is going to help others.
Note 2: Notwithstanding with the answer below, it seems that the examples here do use trimming to get the correct decrypted string.