问题
I'm replacing PKCS7Padding padding with PKCS5Padding for my AES encryptions.
Can I use PKCS5Padding padding algorithm while decryption for already encrypted data using PKCS7Padding?
I tried using a sample program on local and somehow it works and didn't give any error. Just want to ensure if we need any sort of Migration for all the existing records.
For all the existing records, Do I need to decrypt first using PKCS7Padding and then again encrypt using PKCS5Padding and store it back in the DB?
回答1:
You may check the following post https://crypto.stackexchange.com/questions/9043/what-is-the-difference-between-pkcs5-padding-and-pkcs7-padding
PKCS5 and PKCS7 are effectively the same by algorithm, just PKCS5 is defined on 8 byte block (64 bit). Therefore cipher AES/.../PKCS5Padding
is formally incorrect designation, effectively PKCS7 is used.
Do I need to decrypt first using PKCS7Padding and then again encrypt using PKCS5Padding and store it back in the DB?
No, just to change the padding you don't need to do anything
来源:https://stackoverflow.com/questions/53941878/can-i-use-pkcs5padding-padding-algorithm-while-decryption-for-already-encrypted