System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile C# (CSharp) Méthode

HashPasswordForStoringInConfigFile() static private méthode

static private HashPasswordForStoringInConfigFile ( string password, FormsAuthPasswordFormat passwordFormat ) : string
password string
passwordFormat FormsAuthPasswordFormat
Résultat string
		static string HashPasswordForStoringInConfigFile (string password, FormsAuthPasswordFormat passwordFormat)
		{
			if (password == null)
				throw new ArgumentNullException ("password");
			
			byte [] bytes;
			switch (passwordFormat) {
				case FormsAuthPasswordFormat.MD5:
					bytes = MD5.Create ().ComputeHash (Encoding.UTF8.GetBytes (password));
					break;

				case FormsAuthPasswordFormat.SHA1:
					bytes = SHA1.Create ().ComputeHash (Encoding.UTF8.GetBytes (password));
					break;

				default:
					throw new ArgumentException ("The format must be either MD5 or SHA1", "passwordFormat");
			}

			return MachineKeySectionUtils.GetHexString (bytes);
		}
		

Same methods

FormsAuthentication::HashPasswordForStoringInConfigFile ( string password, string passwordFormat ) : string