title: Persistent hashcode for strings
body: <p>I want to generate an integer hashcode for strings, that will stay constant forever; i.e. the same string should always result in the same hashcode.</p>
  
  <p>The hash does not have to be cryptographically secure, it will not be used for passwords or sensitive data.</p>
  
  <p>My first attempt was to use the .net framework string.GetHashCode() function.
  However upon reading the sources I found the following commment:</p>
  
  <blockquote>
  <pre><code>// We want to ensure we can change our hash function daily. 
  // This is perfectly fine as long as you don't persist the
  // value from GetHashCode to disk or count on String A 
  // hashing before string B.  Those are bugs in your code.
  hash1 ^= ThisAssembly.DailyBuildNumber;
  </code></pre>
  </blockquote>
  
  <p>This seems to indicate that the hashcode will not remain constant.</p>
  
  <p>If so, does the framework have another method to generate repeatable hashcodes? Or would the code from GetHashCode be a reasonable starting point to implement my own?</p>
  
  <p>I am looking for something as lightweight and fast as possible.<br>
  I found <a href="https://msdn.microsoft.com/en-us/library/system.security.cryptography.md5%28v=vs.110%29.aspx" rel="noreferrer">System.Security.Cryptography.MD5</a>, but that seems overkill for a simple int32 hashcode, and I am worried about the overhead. At the very least it would require conversion from string to byte array, and from byte array to int, and either creation of a new <code>MD5()</code> object for each hash, or management of some static shared MD5 object().</p>