“Padding is invalid and cannot be removed” using AesManaged

前端 未结 6 889
傲寒
傲寒 2020-11-29 04:55

I\'m trying to get simple encryption/decryption working with AesManaged, but I keep getting an exception when trying to close the decryption stream. The string here gets en

6条回答
  •  星月不相逢
    2020-11-29 05:56

    This exception can be caused by a mismatch of any one of a number of encryption parameters.

    I used the Security.Cryptography.Debug interface to trace all parameters used in the encrypt/decrypt methods.

    Finally I found out that my problem was that I set the KeySize property after setting the Key causing the class to regenerate a random key and not using the key that I was initially set up.

提交回复
热议问题