CryptoStream decrypt encrypt
I have a class to encrypt and decrypt strings but for some reason i get an exception:
System.Security.Cryptography.CryptographicException: 'Padding is invalid and cannot be removed.'
7 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
not related
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Stack Overflow
Padding is invalid and cannot be removed?
I have looked online for what this exception means in relation to my program but can't seem to find a solution or the reason why it's happening to my specific program. I have been using the example
I read this as well... And it does seem to be a padding issue but none of the padding options work... I changed it up a bit and i was able to get the decrypt method to decrypt most of the string.... The last few bits are missing. I ended up adding a few characters to the rawValue string and it decrypted the entire string correctly (with the padding characters I added).
Still so lost
did you set
alg.Padding = PaddingMode.PKCS7;
on both the encryption and decryption Aes object?Yea I did...