Cryptography in ASP.NET stopped working



Dear Fellow Developers,

There is a little bit of code in my web app that encrypts a string, converts
it to base64 string and uses it as a querystring parameter. It then
redirects to this new url. The target url gets this encrypted parameter
(not using Request.QueryString as it replaces the + for a space) and
converts from base64 to normal string then decrypts.

This has been running happily since January this year. There have been no
code changes so the encrypted and decrypted results should be the same.

The web server has recently been upgraded to .NET Framework 2.0, and since
this upgrade odd things have been happening.

I have a copy of the web app on two web servers (dev and live). The dev
server is running .NET 1.1 only and the live .NET 1.1 and 2.0. When I run
the same code against the two servers, I get two slightly different
encrypted strings. The string returned on the .NET 2.0 server is about 16
characters longer. It appeared to add 4 characters in 4 different places.
Consequently, the following exception is thrown:

System.Security.Cryptography.CryptographicException: Length of the data to
decrypt is invalid.
inputBuffer, Int32 inputOffset, Int32 inputCount)

Any ideas?





Sorted now thanks.

For some bizarre reason the encryption routine used UTF8 and the decryption


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question