public string EncryptPassword(string PasswordString, string PasswordFormat)
{
string encryptPassword = "";
if (PasswordFormat == "SHA1")
{
encryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString, "SHA1");
}
else if (PasswordFormat == "MD5")
{
byte[] encryptedBytes = md5.ComputeHash(Encoding.ASCII.GetBytes(PasswordString));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < encryptedBytes.Length; i++)
{
sb.AppendFormat("{0:x2}", encryptedBytes[i]);
}
return sb.ToString().ToUpper();
encryptPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(PasswordString, "MD5");
}
return encryptPassword;
}