It will not work the way you want, but yes encryption is possible, as described below.
Encryption Page:
string id1 = "id1"; Response.Redirect("decryptionPage.aspx?id1=" + HttpUtility.UrlEncode(Encrypt(id1))); private string Encrypt(string stringToEncrypt) { byte[] inputByteArray = Encoding.UTF8.GetBytes(stringToEncrypt); byte[] rgbIV = { 0x21, 0x43, 0x56, 0x87, 0x10, 0xfd, 0xea, 0x1c }; byte[] key = { }; try { key = System.Text.Encoding.UTF8.GetBytes("A0D1nX0Q"); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); return Convert.ToBase64String(ms.ToArray()); } catch (Exception e) { return e.Message; } }
Decryption Page:
string getId1 = Convert.ToString(Request.QueryString["id1"]); var qs = Decrypt(HttpUtility.UrlDecode(getId1)); private string Decrypt(string EncryptedText) { byte[] inputByteArray = new byte[EncryptedText.Length + 1]; byte[] rgbIV = { 0x21, 0x43, 0x56, 0x87, 0x10, 0xfd, 0xea, 0x1c }; byte[] key = { }; try { key = System.Text.Encoding.UTF8.GetBytes("A0D1nX0Q"); DESCryptoServiceProvider des = new DESCryptoServiceProvider(); inputByteArray = Convert.FromBase64String(EncryptedText); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, rgbIV), CryptoStreamMode.Write); cs.Write(inputByteArray, 0, inputByteArray.Length); cs.FlushFinalBlock(); System.Text.Encoding encoding = System.Text.Encoding.UTF8; return encoding.GetString(ms.ToArray()); } catch (Exception e) { return e.Message; } }
source share