本文介绍了我们如何加密查询字符串的值?在另一页解密。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的查询字符串代码:

Response.Redirect("Default.aspx?name=" + txtname.Text + "&add=" + txtaddress.Text + "&email=" + txtemail.Text + "&city=" + txtcity.Text + "&state=" + txtstate.Text + "&zip=" +txtcountry.Text + "&country=" +txtcountry.Text+ "&payment="+txtamount.Text +"&specialcondition="+txtspeclcondition.Text);

推荐答案


Hey Guys I have solved this. Just enjoying by my Code !

//-------- Code For Encrypt----------------------------------

 public string EncryptString(string ClearText)
    {

        byte[] clearTextBytes = Encoding.UTF8.GetBytes(ClearText);

        System.Security.Cryptography.SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();

        MemoryStream ms = new MemoryStream();
        byte[] rgbIV = Encoding.ASCII.GetBytes("ryojvlzmdalyglrj");
        byte[] key = Encoding.ASCII.GetBytes("hcxilkqbbhczfeultgbskdmaunivmfuo");
        CryptoStream cs = new CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV),
   CryptoStreamMode.Write);

        cs.Write(clearTextBytes, 0, clearTextBytes.Length);

        cs.Close();

        return Convert.ToBase64String(ms.ToArray());
    }


//-------- Code For Decrypt----------------------------------



public string DecryptString(string query)
    {
        string result = "";

        try
        {
            MemoryStream ms = null;
            if (query != "")
            {
                string EncryptedText = query;
                EncryptedText = EncryptedText.Replace(' ', '+');

                byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText);
                ms = new MemoryStream();
                System.Security.Cryptography.SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();

                byte[] rgbIV = Encoding.ASCII.GetBytes("ryojvlzmdalyglrj");
                byte[] key = Encoding.ASCII.GetBytes("hcxilkqbbhczfeultgbskdmaunivmfuo");

                CryptoStream cs = new CryptoStream(ms, rijn.CreateDecryptor(key, rgbIV),
                CryptoStreamMode.Write);

                cs.Write(encryptedTextBytes, 0, encryptedTextBytes.Length);

                cs.Close();
                result = Encoding.UTF8.GetString(ms.ToArray());
            }
        }
        catch (Exception ex)
        {
            RecordExceptions(ex);
        }
        return result;
    }


这篇关于我们如何加密查询字符串的值?在另一页解密。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 22:03