Page 1 of 1

Padding/trimming problems using PHP and MySQL AES_DECRYPT()

Posted: Wed Nov 24, 2010 7:29 pm
by mecha_godzilla
Hi,

I'm currently putting some scripts together to test what happens when you encrypt/decrypt data using PHP's AES-128 implementation via mcrypt(), when you use the MySQL implementation and when you use a combination of the two. I wanted to do this to make sure that there weren't any problems with padding, etc. The results so far are:

1. When encrypting and decrypting with PHP no manual padding or trimming is needed.

2. When encrypting and decrypting with MySQL no manual padding or trimming is needed.

3. When encrypting with PHP and decrypting with MySQL a series of NULL characters are appended to the end of the data.

4. When encrypting with MySQL and decrypting with PHP a series of "white square"? characters are appended to the end of the data. Not sure whether this will parse properly but the character copied from my output page looks like ◻

For situation #3, I can use trim() but I'm having problems with situation #4 - I can't tell what this character is or how to get rid of it.

Has anyone encountered this problem or know what the character is?

Thanks,

Mecha Godzilla