Cryptography application block throwing bad data error after migrating application blcoks to 4.1

Topics: Cryptography Application Block
May 21, 2009 at 4:55 PM

Hi All,

I am tyring to migrate my ASP.Net application to 3.5 framework and to Enterprise Library 4.1.

Application encrypts the user passwords and stores the encrypted strings in the database. Application uses TripleDESCryptoServiceProvider to encrypt the password. My existing code to decrypt the passwords is throwing the error "Bad Data".

Does anyone encountered the same issue or know the solution?

My decryption code line looks like this:

decryptedText = Cryptographer.DecryptSymmetric("TripleDESCryptoServiceProvider", str);

Thanks in advance.

May 21, 2009 at 9:29 PM

I think the problem is version compatibility of Cryptography libraries or keys being used.
It is throwing "Bad data" error since I am trying to decrypt the strings with new version that were encrypted with older version.

When I use the old key, that was generated with old version, I get this error:
"Key versions do not match between encrypted key and decryption algorithm"

Is there a workaround to decrypt the encrypted password strings that are encrypted with the older version of the TripleDESCryptoServiceProvider?


May 22, 2009 at 3:27 AM

Did you follow the instructions regarding migrating existing keys? -


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

May 22, 2009 at 3:36 PM

I missed that part.

After I followed the instructions it is working now.

Thank you very much Sarah.