How do I encrypt query strings in aspx.net?
P.S. I realize that this does not offer security. I'm just looking to obfuscate a puzzle.
P.P.S Though I marked CKret's answer as the correct one (for the question as worded I believe his is the most correct answer). However, for myself, I'm just going to try ChoasPandion's alternative to encryption. If I needed more security I'd look at CKret's or Ian's.
-
1Why wouldn't encrypting the querystring offer security, assuming that it was done properly?LukeH– LukeH2009年09月29日 14:26:56 +00:00Commented Sep 29, 2009 at 14:26
-
1Luke, I should have instead said, I'm not looking for "security." I just wanted to avoid a lot of people being focused on security.user179700– user1797002009年09月29日 15:05:34 +00:00Commented Sep 29, 2009 at 15:05
2 Answers 2
Don't bother encrypting it. Just convert it to a base 64 string.
string encoded = Convert.ToBase64String(Encoding.Unicode.GetBytes(myQueryStringValue));
2 Comments
If you trying to hide your product Id's and things like that, then why not just use Encryption?
I guess what you want to do, is to stop people editing the query string to get different results. The simple way to do this, is to add a Hash of the query string to the query string, and have some base-page functionality check that the hash is correct for the request, identifing tampered query strings.
1 Comment
Explore related questions
See similar questions with these tags.