/// <summary> /// The encrypt password. /// </summary> /// <param name="pass"> /// The pass. /// </param> /// <param name="passwordFormat"> /// The password format. /// </param> /// <param name="salt"> /// The salt. /// </param> /// <returns> /// The <see cref="string"/>. /// </returns> private static string EncryptPassword(string pass, MembershipPasswordFormat passwordFormat, string salt) { var hashAlgorithmType = HashHelper.HashAlgorithmType.SHA1; try { Membership.HashAlgorithmType.ToEnum <HashHelper.HashAlgorithmType>(); } catch (Exception exception) { hashAlgorithmType = HashHelper.HashAlgorithmType.SHA1; } switch (passwordFormat) { case MembershipPasswordFormat.Clear: return(pass); case MembershipPasswordFormat.Hashed: return(HashHelper.Hash( pass, hashAlgorithmType, salt, false, HashHelper.HashCaseType.None, null, false)); case MembershipPasswordFormat.Encrypted: var passwordManager = new YafMembershipProvider(); return(passwordManager.GetClearTextPassword(pass)); } return(pass); }
private static string EncryptPassword(string pass, MembershipPasswordFormat passwordFormat, string salt) { switch (passwordFormat) { case MembershipPasswordFormat.Clear: return(pass); case MembershipPasswordFormat.Hashed: return(HashHelper.Hash( pass, HashHelper.HashAlgorithmType.SHA1, salt, false, HashHelper.HashCaseType.None, "", false)); case MembershipPasswordFormat.Encrypted: var passwordManager = new YafMembershipProvider(); return(passwordManager.GetClearTextPassword(pass)); } return(pass); }