Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have written this code and working properly.bt i dont knw how to encode and decode values..
can any one give me solution about hiding the values in the URL..

C#
protected void btnadd_Click(object sender, EventArgs e)
    {
        string username = txtusername.Text;
        string mname = txtmname.Text;
        string lname = txtlname.Text;
Response.Redirect("QueryString2.aspx?name="+username+"&name2="+mname+"&name3="+lname);

    }
Posted

Check this HTTP module out that lets you encrypt the entire query string here at http://madskristensen.net/post/HttpModule-for-query-string-encryption.aspx[^]

Regards
Pawan
 
Share this answer
 
Please follow the link below

Encrypt and Decrypt Data with C#[^]

Thanks
 
Share this answer
 
C#
private static string EncryptionKey = "!#853g`de";
private static byte[] key = { };
private static byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };

//Encryption Technique:

public string Encrypt(string Input)
        {
          try
           {
                key = System.Text.Encoding.UTF8.GetBytes(EncryptionKey.Substring(0, 8));
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                Byte[] inputByteArray = Encoding.UTF8.GetBytes(Input);
                MemoryStream ms = new MemoryStream();
                CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                return Convert.ToBase64String(ms.ToArray());
          }
         catch (Exception ex)
         {
           return "";
         }
       }

//Decryption Technique :

public string Decrypt(string Input)
        {
            Byte[] inputByteArray = new Byte[Input.Length];

            try
            {
                key = System.Text.Encoding.UTF8.GetBytes(EncryptionKey.Substring(0, 8));
                DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                inputByteArray = Convert.FromBase64String(Input);
                MemoryStream ms = new MemoryStream();
                CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write);
                cs.Write(inputByteArray, 0, inputByteArray.Length);
                cs.FlushFinalBlock();
                Encoding encoding = Encoding.UTF8;
                return encoding.GetString(ms.ToArray());
            }
            catch (Exception ex)
            {
                return "";
            }
        }
 
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