Hi Group,

I just start learning BC for AES encryption/decryption and am using 
AES/CBC/PKCS7PADDING for 256 bits.

BC can encrypt and decrypt text successfully, however after decryption I notice 
that there are always a few padding of null (0x00), which therefore fails my 
hash comparison. For example, suppose original input string is "1234567890", 
the decrypted byte array is always 
{0x49,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x48,0x00,0x00,0x00,0x00,0x00,0x00}.

Why the padding is not 0x06,0x06,0x06,0x06,0x06,0x06? And is there any way to 
deterministically tell the padding length (could be 0) after encryption so that 
I can get exactly the same string before encryption?

Thanks a lot!

Roger

Reply via email to