title: .Net core string hash using SHA256
body: <p>Hello SO community I need some hashing expertise:</p>
  
  <h3>some context</h3>
  
  <p>I am faced with the problem to compare two lists of objects. One instance of the list is in a .Net Core 2.0 application and the other in a .Net 4.5.2 application. </p>
  
  <p>To compare the two lists (ensure that they are the same in both applications) I would like to calculate a hash of the list and exchange that between the apps.
  To calculate a hash of the list I'm using the approach described <a href="https://stackoverflow.com/a/30758270/4286538">in this answer</a>.</p>
  
  <p>For this you need a hashcode of the objects in the list, and this is where my problem comes in: It seems a well known fact <a href="https://andrewlock.net/why-is-string-gethashcode-different-each-time-i-run-my-program-in-net-core/" rel="nofollow noreferrer">(1)</a> that .Net core uses <em>randomised hash code behaviour</em> for strings. To calculate the hashcode of my objects I would need to include hashcodes of strings. </p>
  
  <p>Leading to my question:
  <strong>Is it a good idea to calculate a hash of a string using SHA256?</strong></p>
  
  <p>The reasons why I would like to use it:</p>
  
  <ul>
  <li>Same output size (256 bit can be interpreted Int32)</li>
  <li>SHA should always produce the same output (also for future .Net/core versions)</li>
  <li>It is easier to share between the applications than a custom implementation</li>
  </ul>
  
  <p><strong>Are there better (more efficient, easier, less collisions) alternatives?</strong></p>