title: How to generate HMAC-SHA256 in .Net Core?
body: <p>I am using this page to generate some test HMAC-SHA256 hashes for some texts: </p>
  
  <p><a href="https://www.liavaag.org/English/SHA-Generator/HMAC/" rel="noreferrer">https://www.liavaag.org/English/SHA-Generator/HMAC/</a></p>
  
  <p>However, when I try to use the approach in <a href="https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/consumer-apis/password-hashing" rel="noreferrer">this MSDN guide</a> in my .Net Core project, I do not get the same results. Could some one explain to me how to get identical results to those I get from the previous web page in my C# code?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>// My own GetHash method usage:
  var hashed = PasswordHelper.GetHash("Test", Encoding.UTF8.GetBytes("123"));
  
  public static string GetHash(string password, byte[] salt)
  {
      // derive a 256-bit subkey (use HMACSHA1 with 10,000 iterations)
      string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2(
          password: password,
          salt: salt,
          prf: KeyDerivationPrf.HMACSHA256,
          iterationCount: 10000,
          numBytesRequested: 256 / 8));
      return hashed;
  }
  </code></pre>