web application password encryption code example
Example: encrypt password easiest way in web app .net
public static string HashPassword(string password, string algorithm = "sha256")
{
return Hash(Encoding.UTF8.GetBytes(password), algorithm);
}
private static string Hash(byte[] input, string algorithm = "sha256")
{
using (var hashAlgorithm = HashAlgorithm.Create(algorithm))
{
return Convert.ToBase64String(hashAlgorithm.ComputeHash(input));
}
}