public static string MakePbkdf2String(this IKeyedHashFunction hash, string input, byte[] salt, int length, int iterationCount) { var data = Encoding.UTF8.GetBytes(input); var result = hash.MakePbkdf2(data, salt, length, iterationCount); return(Convert.ToBase64String(result)); }
public static bool VerifyPbkdf2(this IKeyedHashFunction hash, byte[] hashed, byte[] otherData, byte[] salt, int iterationCount) { int length = hashed.Length; var otherHashed = hash.MakePbkdf2(otherData, salt, length, iterationCount); if (otherHashed.Length != hashed.Length) { return(false); } return(ByteArraysEqual(hashed, otherHashed)); }