1

I need to hash user password into a .net core project with an algorithm which is more secure and fast generate method.

I don't want to add any external packages to my project

Behrooz
  • 33
  • 4
  • Does this answer your question? [How to hash a password](https://stackoverflow.com/questions/4181198/how-to-hash-a-password) – Progman Dec 14 '19 at 18:49

1 Answers1

2

you can use this method

public string GetSha256Hash(string input)
{
   using (var hashAlgorithm = new SHA256CryptoServiceProvider())
   {
        var byteValue = Encoding.UTF8.GetBytes(input);
        var byteHash = hashAlgorithm.ComputeHash(byteValue);
        return Convert.ToBase64String(byteHash);
    }
}
Mohammad
  • 921
  • 7
  • 15