public static ComputePasswordHash ( string password, string salt, int iterations = HashIterations ) : string | ||
password | string | |
salt | string | |
iterations | int | |
return | string |
public static string ComputePasswordHash(string password, string salt, int iterations = HashIterations)
{
// Convert salt to byte array
byte[] saltBytes = Encoding.UTF8.GetBytes(salt);
// Hash using PBKDF2 with salt and predefined iterations
using (Rfc2898DeriveBytes pbkdf2 = new Rfc2898DeriveBytes(password, saltBytes, iterations))
{
var key = pbkdf2.GetBytes(64);
return Convert.ToBase64String(key);
}
}