using System.Web.Security;
using System.Security.Cryptography;
public static void Main()
string mySalt = "e9a24b00-f163-4b94-9870-0d0eea70eda1";
string myPwd = "Minitab1829";
string hashedPwd1 = HashPassword1(myPwd, mySalt);
Console.WriteLine(hashedPwd1);
string hashedPwd2 = HashPassword2(myPwd, mySalt);
Console.WriteLine(hashedPwd2);
public static string HashPassword1(string password, string salt)
string returnValue = string.Empty;
StringBuilder sb = new StringBuilder();
int maxLength = password.Length;
if (salt.Length > password.Length)
for (int i = 0; i < maxLength; ++i)
returnValue = FormsAuthentication.HashPasswordForStoringInConfigFile(sb.ToString(), "SHA1");
public static string HashPassword2(string password, string salt)
StringBuilder sb = new StringBuilder();
if (password != null && salt != null)
int maxLength = password.Length;
if (salt.Length > password.Length)
for (int i = 0; i < maxLength; ++i)
byte[] buffer = Encoding.UTF8.GetBytes(sb.ToString());
using (SHA1CryptoServiceProvider cryptoService = new SHA1CryptoServiceProvider())
result = BitConverter.ToString(cryptoService.ComputeHash(buffer)).Replace("-", "");