<p>I need to encrypt and decrypt a querystring in ASP.NET. </p>

<p>The querystring might look something like this:</p>

<blockquote>
  <p><a href="http://www.mysite.com/report.aspx?id=12345&amp;year=2008" rel="noreferrer">http://www.mysite.com/report.aspx?id=12345&amp;year=2008</a></p>
</blockquote>

<p>How do I go about encrypting the entire querystring so that it looks something like the following?</p>

<blockquote>
  <p><a href="http://www.mysite.com/report.aspx?crypt=asldjfaf32as98df8a" rel="noreferrer">http://www.mysite.com/report.aspx?crypt=asldjfaf32as98df8a</a></p>
</blockquote>

<p>And then, of course, how to I decrypt it? What's the best encryption to use for something like this? TripleDES?</p>

I can't give you a turn key solution off the top of my head, but you should avoid TripleDES since it is
not as secure as other encryption methods
.
If I were doing it, I'd just take the entire URL (domain and querystring) as a
URI object
, encrypt it with one of the
built-in .NET libraries
and supply it as the
```
crypt
```
object. When I need to decrypt it, do so, then create a new URI object, which will let you get everything back out of the original querystring.