title: SQL bigint hash to match c# int64 hash
body: <p>I am trying to create a universal hashing alogrithim that hashes a string as a 64 bit int.</p>
  
  <p>I am able to hash the strings correctly:
  sql:</p>
  
  <pre><code>select  
      convert
      (
          varchar(64),
          HASHBYTES
          (
              'SHA1',
              'google.com'
          ),
          2
      )
  </code></pre>
  
  <p>returns <code>BAEA954B95731C68AE6E45BD1E252EB4560CDC45</code></p>
  
  <p>C#</p>
  
  <pre><code>    System.Security.Cryptography.SHA1 c = System.Security.Cryptography.SHA1.Create();
      System.Text.StringBuilder sb = new StringBuilder();
      byte[] b = c.ComputeHash(Encoding.UTF8.GetBytes("google.com"));
      for (int i = 0; i &lt; b.Length;i++ )
      {
          byte by = b[i];
          sb.Append(by.ToString("x2").ToUpper());
      }
  
      return sb.ToString();
  </code></pre>
  
  <p>retruns <code>BAEA954B95731C68AE6E45BD1E252EB4560CDC45</code></p>
  
  <p>However when I convert to a bigint/long the values do not match:
  sql:</p>
  
  <pre><code>select  
      convert
      (
          bigint,
          HASHBYTES
          (
              'SHA1',
              'google.com'
          )
      )
  </code></pre>
  
  <p>returns <code>2172193747348806725</code></p>
  
  <p>c#:</p>
  
  <pre><code>    System.Security.Cryptography.SHA1 c = System.Security.Cryptography.SHA1.Create();
      byte[] b = c.ComputeHash(Encoding.UTF8.GetBytes("google.com"));
      return BitConverter.ToInt64(b, 0);
  </code></pre>
  
  <p>returns <code>7501998164347841210</code></p>
  
  <p>Any ideas on how to get these numbers to match?</p>