Below is a DES 2 way crypto functions. Just put it in a class in the app_code folder and you can call encrypt/decript for a string like your QS - encrypt("c=test&i=1&id=2").
Because you are using the result in a url querystring I think you need to html encode and decode them first to make sure any special characters aren't altered in that way.
server.htmlencode(encrypt("..."))
server.htmldecode(decrypt("..."))
There is also tripleDES crypto for extra strong security but it uses extra resources and would be overkill for this purpose.
Code:
' at top of pg
Imports Microsoft.VisualBasic
Imports System.IO
Imports System.Security.Cryptography
'8 bytes randomly selected for both the Key and the Initialization Vector
'the IV is used to encrypt the first block of text so that any repetitive
'patterns are not apparent
'=======CHANGE THESE NUMBERS ===========
Private Shared KEY_64() As Byte = {13, 56, 211, 176, 129, 4, 213, 222}
Private Shared IV_64() As Byte = {52, 143, 26, 173, 236, 9, 112, 39}
''' <summary>
''' Standard DES encryption
''' </summary>
''' <param name="value">string to encrypt</param>
''' <returns>encrypted string</returns>
''' <remarks></remarks>
Public Shared Function Encrypt(ByVal value As String) As String
If value <> "" Then
Dim cryptoProvider As DESCryptoServiceProvider = _
New DESCryptoServiceProvider()
Dim ms As MemoryStream = New MemoryStream()
Dim cs As CryptoStream = _
New CryptoStream(ms, cryptoProvider.CreateEncryptor(KEY_64, IV_64), _
CryptoStreamMode.Write)
Dim sw As StreamWriter = New StreamWriter(cs)
sw.Write(value)
sw.Flush()
cs.FlushFinalBlock()
ms.Flush()
'convert back to a string
Return Convert.ToBase64String(ms.GetBuffer(), 0, ms.Length)
Else
Return String.Empty
End If
End Function
''' <summary>
''' Standard DES decryption
''' </summary>
''' <param name="value">string to decrypt</param>
''' <returns>decrypt string</returns>
''' <remarks></remarks>
Public Shared Function Decrypt(ByVal value As String) As String
If value <> "" Then
Dim cryptoProvider As DESCryptoServiceProvider = _
New DESCryptoServiceProvider()
'convert from string to byte array
Dim buffer As Byte() = Convert.FromBase64String(value)
Dim ms As MemoryStream = New MemoryStream(buffer)
Dim cs As CryptoStream = _
New CryptoStream(ms, cryptoProvider.CreateDecryptor(KEY_64, IV_64), _
CryptoStreamMode.Read)
Dim sr As StreamReader = New StreamReader(cs)
Return sr.ReadToEnd()
Else
Return String.Empty
End If
End Function