Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not sure why yours isn't working, but when I wrote the SHA512 implementation below I had some issues with the hash. It doesn't output like you would normally see it displayed for humans. For this reason your data type should be binary in the database. Also here is the implementation I use (with the salt changed) that uses SHA512. Using ByteArrayToHexString puts it in a human recognizable format. Then you can use a varchar in the database.</p> <pre><code> /// &lt;summary&gt; /// Takes a string as input, SHA512 hashes it, and returns the hexadecimal representation of the hash as a string. /// &lt;/summary&gt; /// &lt;param name="toHash"&gt;string to be hashed&lt;/param&gt; /// &lt;returns&gt;hexadecimal representation of the hash as a string&lt;/returns&gt; private string GetHash(string toHash) { /* As of this writing, both the –Cng and –CryptoServiceProvider implementation classes are FIPS-certified, * but –Managed classes are not. http://msdn.microsoft.com/en-us/magazine/ee321570.aspx */ // Salt the string toHash = "%my" + toHash.Insert(Convert.ToInt16(toHash.Length / 2), "!secret") + ".sauce#"; SHA512CryptoServiceProvider hasher = new SHA512CryptoServiceProvider(); byte[] hashBytes = hasher.ComputeHash(Encoding.Unicode.GetBytes(toHash)); hasher.Clear(); return ByteArrayToHexString(hashBytes); } /// &lt;summary&gt; /// Takes a byte[] and converts it to its string hexadecimal representation /// &lt;/summary&gt; /// &lt;param name="ba"&gt;Array of bytes[] to convert&lt;/param&gt; /// &lt;returns&gt;string, hexadecimal representation of input byte[]&lt;/returns&gt; private string ByteArrayToHexString(byte[] ba) { StringBuilder hex = new StringBuilder(ba.Length * 2); foreach (byte b in ba) hex.AppendFormat("{0:x2}", b); return hex.ToString(); } </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.
    3. VO
      singulars
      1. This table or related slice is empty.
    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