JAVA使用AES/CBC/PKCS5模式加密的内容,怎样在C#下解密
JAVA使用AES/CBC/PKCS5方式加密的内容,怎样在C#下解密?
我用C#解密一个JAVA的AES加密数据,一直报“填充无效,无法被移除。”的异常。
加密数据的填充方式是PKCS5的,但C#里的填充方式只有PKCS7选项,是不是因为这个导致错误呢。
如果要解密应该怎样做呢?
------解决方案--------------------
PKCS5 and PKCS7 use the same padding algorithm so you don't need to change anything. (If you wanted to use a different padding though, you can try changing the DSACryptoServiceProvider.Padding property or do the padding manually.)
http://social.msdn.microsoft.com/Forums/en-US/13a20d89-7d84-4f7d-8f5c-5ae108a7f5cf/des-encryption-padding-mode-pkcs5?forum=csharplanguage
我用C#解密一个JAVA的AES加密数据,一直报“填充无效,无法被移除。”的异常。
加密数据的填充方式是PKCS5的,但C#里的填充方式只有PKCS7选项,是不是因为这个导致错误呢。
如果要解密应该怎样做呢?
------解决方案--------------------
PKCS5 and PKCS7 use the same padding algorithm so you don't need to change anything. (If you wanted to use a different padding though, you can try changing the DSACryptoServiceProvider.Padding property or do the padding manually.)
http://social.msdn.microsoft.com/Forums/en-US/13a20d89-7d84-4f7d-8f5c-5ae108a7f5cf/des-encryption-padding-mode-pkcs5?forum=csharplanguage