/// <summary> /// Used to Generate a second hash {SHA512} based on the SHA1 password hash and the private salt. /// </summary> /// <param name="passwordSha1HashBase64">{string} SHA1 password Hash base 64.</param> /// <param name="passwordPrivateSalt">{string} Password Salt either from the database or a newly generated salt.</param> /// <returns>{string} base 64 Passwrod SHA512 hash.</returns> public static string GenerateSha512HashBase64(string passwordSha1HashBase64, string passwordPrivateSalt) { HashAlgorithm secondHasher = new SHA512CryptoServiceProvider(); byte[] secondHash = secondHasher.ComputeHash(PasswrodHelper.CombineSalt(Convert.FromBase64String(passwordSha1HashBase64), Convert.FromBase64String(passwordPrivateSalt))); return(Convert.ToBase64String(secondHash)); }
/// <summary> /// Used to Generate an SHA1 password hash based on the plain text password and the public salt. /// </summary> /// <param name="plainTextPassword">{string} Plain text password.</param> /// <param name="passwordPublicSalt">{string} Password Salt either from the database or a newly generated salt.</param> /// <returns>{string} base 64 Passwrod SHA1 hash.</returns> public static string GenerateSha1HashBase64(string plainTextPassword, string passwordPublicSalt) { HashAlgorithm firstHasher = new SHA1CryptoServiceProvider(); byte[] firstHash = firstHasher.ComputeHash(PasswrodHelper.CombineSalt(System.Text.Encoding.UTF8.GetBytes(plainTextPassword), Convert.FromBase64String(passwordPublicSalt))); return(Convert.ToBase64String(firstHash)); }