Question: write algorithm for this code. public static class Hashing { public static string Salt() { byte[] salt = new byte[128 / 8]; using (var rng
write algorithm for this code.
public static class Hashing { public static string Salt() { byte[] salt = new byte[128 / 8]; using (var rng = RandomNumberGenerator.Create()) { rng.GetBytes(salt); } return Convert.ToBase64String(salt); } public static string HashPassword(string password, string salt) { string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2( password, Convert.FromBase64String(salt), KeyDerivationPrf.HMACSHA1, 10000, 256 / 8 )); return hashed; }
public static bool VerifyPassword(string password, string hash, string salt) { string hashedPassword = Convert.ToBase64String(KeyDerivation.Pbkdf2( password, Convert.FromBase64String(salt), KeyDerivationPrf.HMACSHA1, 10000, 256 / 8 )); return hash == hashedPassword; } private static readonly byte[] Pepper = ConvertSpacedHexToByteArray(ConfigurationManager.AppSettings["Pepper"]); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
