Click here to Skip to main content
16,004,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

This is one of those strange questions when I'm not even sure what to google for!

But here's my problem, I'm using Rijndael encryption to encrypt some values in the database. I can pull back this cipher text fine, but then I need to pass this to a generic handler through the query string.

So if the DB record looks like this:
WLIOrjH/zKAEGNSU6XHaqYoXFLmEZ6Y4KBLjpCQowIxGNfS/btNfn2Je72DT2zm4fIpZSLepR/DwIGdtyUJ+zb+DIkItdYhLwaqvEiX9Y+BuS6F0vAfNj0HV1PR6g6z347QXgN1L2bgL2QrzeySBSQ==


The query string will look like this:
WLIOrjH%2fzKAEGNSU6XHaqYoXFLmEZ6Y4KBLjpCQowIxGNfS%2fbtNfn2Je72DT2zm4fIpZSLepR%2fDwIGdtyUJ+zb+DIkItdYhLwaqvEiX9Y+BuS6F0vAfNj0HV1PR6g6z347QXgN1L2bgL2QrzeySBSQ%3d%3d


Notice how the "=" have been change to %3d etc. Now when I assign this version of the cipher text to a string it changes to the following:
WLIOrjH/zKAEGNSU6XHaqYoXFLmEZ6Y4KBLjpCQowIxGNfS/btNfn2Je72DT2zm4fIpZSLepR/DwIGdtyUJ zb DIkItdYhLwaqvEiX9Y BuS6F0vAfNj0HV1PR6g6z347QXgN1L2bgL2QrzeySBSQ==


This time notice the "+" have been lost and replace by a space. This then breaks me decryption method and an error is thrown.

I'm guessing I need to do some form of encoding but i'm not sure were to start.

Any ideas?
Phil
Posted

More info, from this article http://www.w3schools.com/TAGS/ref_urlencode.asp[^] it says that "+" are replaced by spaces. I've added a quick string.replace to change these back but if anyone has any further info on if this will be sufficient then that would be great!

Phil
 
Share this answer
 
When encoding the text use Server.UrlEncode(yourString); likewise, Server.UrlDecode(theEncodedString) will need to be used on the other side.

Cheers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900