2017-06-15 67 views
0

我是網絡開發新手。我正在開發我的課程項目,使我在網站中訪問數據。我想從那裏爲用戶隱藏這些數據,以便他們在將來無法更改它。 我正在ASP.net上工作。幫助將不勝感激。隱藏網址中的數據

回答

1

您不能隱藏數據的URL 行駛,就像我的網址是text.aspx?姓=羅賓&姓氏=胡德 您可以在網址 加密數據,那麼是應該顯示像Test.aspx的?姓= 121sdnasdkjn121928 &姓氏= sadklsdn12981029 類似的東西 ,然後你在哪裏得到的數據,你需要解密的數據,它將返回實際的數據

這裏是加密或解密

public static string Encrypt(string clearText) 
    { 
     try 
     { 
      string EncryptionKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890"; 
      byte[] clearBytes = Encoding.Unicode.GetBytes(clearText); 
      using (Aes encryptor = Aes.Create()) 
      { 
       Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 }); 
       encryptor.Key = pdb.GetBytes(32); 
       encryptor.IV = pdb.GetBytes(16); 
       using (MemoryStream ms = new MemoryStream()) 
       { 
        using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write)) 
        { 
         cs.Write(clearBytes, 0, clearBytes.Length); 
         cs.Close(); 
        } 
        clearText = Convert.ToBase64String(ms.ToArray()); 
       } 
      } 
      return clearText; 
     } 
     catch 
     { 
      return null; 
     } 
    } 

    public static string Decrypt(string cipherText) 
    { 
     try 
     { 
      string EncryptionKey = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz1234567890"; 
      byte[] cipherBytes = Convert.FromBase64String(cipherText.Replace(" ", "+")); 

      using (Aes encryptor = Aes.Create()) 
      { 
       Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 }); 
       encryptor.Key = pdb.GetBytes(32); 
       encryptor.IV = pdb.GetBytes(16); 
       using (MemoryStream ms = new MemoryStream()) 
       { 
        using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write)) 
        { 
         cs.Write(cipherBytes, 0, cipherBytes.Length); 
         cs.Close(); 
        } 
        cipherText = Encoding.Unicode.GetString(ms.ToArray()); 
       } 
      } 
      return cipherText; 
     } 
     catch 
     { 
      return null; 
     } 
    } 
功能

OR

可以使用術語URL路由,以及以隱藏真實的URL,並顯示虛假的URL用戶 喜歡以代替localhost:1544/Test.aspx文件,它會顯示本地主機:1544 /測試或本地主機:1544/what_ever_you_want 它會隱藏.aspx擴展名以及

希望這會幫助

1

您無法隱藏在URL中傳輸的數據。發送未在url中顯示的數據的最簡單方法是使用POST請求而不是GET請求。