title: Hashing a password using SHA256 and .NET/Node.js
body: <p>Im Storing SHA256 hashes of user passwords in my database generated by .NET and I need to be able to check them with Node.js. The only problem is that .NET and Node.js create different hashes for the same password.</p>
  
  <pre><code>Password: ThisPassword  
  </code></pre>
  
  <h2>.NET:</h2>
  
  <pre><code>var ue = new UnicodeEncoding();  
  var byteSourceText = ue.GetBytes("ThisPassword");  
  var byteHash = new System.Security.Cryptography.SHA256Managed().ComputeHash(byteSourceText);  
  return Convert.ToBase64String(byteHash);
  
  //Tlwxyd7HIQhXkN6DrWJtmB9Ag2fz84P/QgMtbi9XS6Q=
  </code></pre>
  
  <h2>Node.js (Using Crypto):</h2>
  
  <pre><code>var crypto = require('crypto');
  return crypto.createHash('sha256').update('ThisPassword').digest('base64')
  
  //d7I986+YD1zS6Wz2XAcDv2K8yw3xIVUp7u/OZiDzhSY=
  </code></pre>
  
  <p>I found <a href="https://stackoverflow.com/questions/10559203/sha-256-hashes-different-between-c-sharp-and-javascript">this</a>, but was unable to figure out how to implement his solution.</p>