Exemplo n.º 1
0
        public void GenerateSha1_returns_correct_result()
        {
            foreach (var i in _testDataSha1)
            {
                var expected = i.Expected.DecodeHex();

                Assert.AreEqual(expected,
                                Pbkdf2.GenerateSha1(i.Password, i.Salt, i.IterationCount, expected.Length));
                Assert.AreEqual(expected,
                                Pbkdf2.Generate <HMACSHA1>(i.Password, i.Salt, i.IterationCount, expected.Length));
            }
        }
Exemplo n.º 2
0
            public byte[] Derive(byte[] password, byte[] salt)
            {
                switch (HashMethod)
                {
                case HashMethodType.Sha1:
                    return(Pbkdf2.GenerateSha1(password, salt, Iterations, 32));

                case HashMethodType.Sha256:
                    return(Pbkdf2.GenerateSha256(password, salt, Iterations, 32));
                }

                throw new InternalErrorException($"Unknown hash method {HashMethod}");
            }