For decryption to be successful, the key used for decryption
must match that used for encryption.
If a password-derived key is being used, make sure that the passwords used to
generate the encryption and decryption keys match, and
also that the current cryptographic service providers involved are the same.
If key size is not explicitly specified in the GenerateKeyFromPassword method,
the default key size is 40 bits with the Microsoft Base CSP,
and 128 bits with the Microsoft Enhanced or Strong CSP. As
a result, the keys may mismatch.
Use the debug statement
Response.Write Key.Length
to make sure the key lengths match during encryption and decryption.
Cryptographic Service Providers are covered in the chapter
Symmetric Encryption
of the AspEncrypt.com web site.