Cryptography in ASP.NET stopped working

L

landers

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.
at
System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[]
inputBuffer, Int32 inputOffset, Int32 inputCount)

Any ideas?

Landers
 
L

landers

Sorted now thanks.

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

Landers
 

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top