using System.Text;using System.Web.Security;using System.Security.Cryptography;
public static string HashPassword(string plainMessage){byte[] data = Encoding.UTF8.GetBytes(plainMessage);using (HashAlgorithm sha = new SHA256Managed()){byte[] encryptedBytes = sha.TransformFinalBlock(data, 0, data.Length);return Convert.ToBase64String(sha.Hash);}}
private MembershipPasswordFormat passwordFormat;passwordFormat = MembershipPasswordFormat.Hashed;if (passwordFormat == MembershipPasswordFormat.Hashed){string newPassword = "Type your new pwd here"txtpswd.Text = HashPassword(newPassword);}