Can I use PKCS5Padding padding algorithm while decryption for already encrypted data using PKCS7Padding?

久未见 提交于 2019-12-11 11:56:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!