title: How do I create a HashCode in .net (c#) for a string that is safe to store in a database?
body: <p>To quote from <a href="http://ericlippert.com/2011/02/28/guidelines-and-rules-for-gethashcode/">Guidelines and rules for GetHashCode</a>  by  Eric Lippert:</p>
  
  <blockquote>
    <p>Rule: <strong>Consumers of GetHashCode cannot rely upon it being stable over time or across appdomains</strong></p>
    
    <p>Suppose you have a Customer object
    that has a bunch of fields like Name,
    Address, and so on. If you make two
    such objects with exactly the same
    data in two different processes, they
    do not have to return the same hash
    code. If you make such an object on
    Tuesday in one process, shut it down,
    and run the program again on
    Wednesday, the hash codes can be
    different.</p>
    
    <p>This has bitten people in the past.
    The documentation for
    System.String.GetHashCode notes
    specifically that two identical
    strings can have different hash codes
    in different versions of the CLR, and
    in fact they do. <strong>Don't store string hashes in databases and expect them to be the same forever, because they won't be.</strong></p>
  </blockquote>
  
  <p>So what is the correct way to create a HashCode of a string that I can store in a database?   </p>
  
  <p>(Please tell me I am not the first person to have left this bug in software I have written!)</p>