public static void SaveHash(string Password) { byte[] Key = Encoding.UTF8.GetBytes(Password); byte[] Salt = CryptoFunctions.GenerateCryptoSecureBytes(Settings.Hash.SaltBytes); byte[] Hash = CryptoFunctions.DeriveKey(Key, Salt, Settings.Hash.HashBytes, Settings.Hash.HashPBKDF2Iterations); EncodingStream es = new EncodingStream(File.Open(Settings.Files.HashPath, FileMode.CreateNew)); es.WriteBytes(Salt); es.WriteBytes(Hash); es.Close(); }
public bool CheckCandidate(string candidate) { byte[] candidateBytes = Encoding.UTF8.GetBytes(candidate); byte[] candidateHash = CryptoFunctions.DeriveKey(candidateBytes, this.Salt, Settings.Hash.HashBytes, Settings.Hash.HashPBKDF2Iterations); return(CryptoFunctions.SlowEquals(this.Hash, candidateHash)); }