Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hii all, thank you for your assistance... and i got some difference sort of solution from some other sites. i don't know that the best solution. that is to encode the value using an encryption and decryption algorithm... The sample code has been written like this...</p> <pre><code>&lt;a href='Page1.aspx?UserID=&lt;%= HttpUtility.UrlEncode(TamperProofStringEncode("5","F44fggjj")) %&gt;'&gt; Click Here&lt;/a&gt; &lt;!--Created one anchor tag and call the function for TamperProofStringEncode--&gt; </code></pre> <hr> <pre><code> private string TamperProofStringEncode(string value, string key) { System.Security.Cryptography.MACTripleDES mac3des = new System.Security.Cryptography.MACTripleDES(); System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); mac3des.Key = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(key)); return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(value)) + "-" + Convert.ToBase64String(mac3des.ComputeHash(System.Text.Encoding.UTF8.GetBytes(value))); } </code> </pre> <hr> <p>In the page load of 'Page1' call the decode algorithm to decode the query string</p> <pre><code>try { string DataString = TamperProofStringDecode(Request.QueryString["UserID"], "F44fggjj"); Response.Write(DataString); } catch (Exception ex) { Response.Write(ex.Message); } </code></pre> <hr> <pre><code>private string TamperProofStringDecode(string value, string key) { string dataValue = ""; string calcHash = ""; string storedHash = ""; System.Security.Cryptography.MACTripleDES mac3des = new System.Security.Cryptography.MACTripleDES(); System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); mac3des.Key = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(key)); try { dataValue = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(value.Split('-')[0])); storedHash = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(value.Split('-')[1])); calcHash = System.Text.Encoding.UTF8.GetString(mac3des.ComputeHash(System.Text.Encoding.UTF8.GetBytes(dataValue))); if (storedHash != calcHash) { //'Data was corrupted throw new ArgumentException("Hash value does not match"); // 'This error is immediately caught below } } catch (Exception ex) { throw new ArgumentException("Invalid TamperProofString"); } return dataValue; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload