title: Case Insensitive hash (SHA) of a string
body: <p>I’m passing a name string and its SHA1 value into a database. The SHA value is used as an index for searches. After the implementation was done, we got the requirement to make searching the name case insensitive. We do need to take all languages into account (Chinese characters are a real use case). </p>
  
  <p>I know about the <a href="https://stackoverflow.com/questions/2256453/using-invariantcultureignorecase-instead-of-toupper-for-case-insensitive-string">Turkey Test</a>. How can I transform my input string before hashing to be case insensitive? Ideally I’d like it to be equivalent of <a href="http://msdn.microsoft.com/en-us/library/system.stringcomparer.invariantcultureignorecase.aspx" rel="nofollow noreferrer">InvariantCultureIgnoreCase</a>.</p>
  
  <p>In other words, how do I make the output of this function case insensitive?</p>
  
  <pre><code>private byte[] ComputeHash(string s)
  {
       byte[] data = System.Text.Encoding.Unicode.GetBytes(s ?? string.Empty);
       SHA1 sha = new SHA1CryptoServiceProvider();     // returns 160 bit value
       return sha.ComputeHash(data);
  }
  </code></pre>
  
  <p>If SHA isn’t possible, I might be able to make <a href="http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx" rel="nofollow noreferrer">String.GetHashCode</a>() work, but I don’t see a way to make that case insensitive either.</p>
  
  <p>I'm betting this isn't possible. If its not, what are some work arounds?</p>