Hashing
public static string Hash(string username, string value)
{
var passwordHasher = new PasswordHasher<string>();
string hashedText = passwordHasher.HashPassword(username, value);
return hashedText;
}
public static bool VerifyHashedValue(string username, string hashedValue, string providedValue)
{
var passwordHasher = new PasswordHasher<string>();
var verificationResult = passwordHasher.VerifyHashedPassword(username, hashedValue, providedValue);
return verificationResult == PasswordVerificationResult.Success;
}
Note: in the references, here is the official documentation about hashing passwords in .NET Core. But Microsoft recommends using PasswordHasher in new apps.