コード例 #1
0
        static void GenerateHashWithSalt()
        {
            var data = "P@ssw0rd";
            var hash = HashFunctions.GenerateHashWithSalt(data);

            Console.WriteLine(hash);

            var data2 = "P@ssw1rd";
            var hash2 = CryptoHelper.GenerateBase64(HashFunctions.SaltSize + HashFunctions.HashSize);

            Assert.IsTrue(HashFunctions.VerifyByHashWithSalt(data, hash));
            Assert.IsFalse(HashFunctions.VerifyByHashWithSalt(data2, hash));
            Assert.IsFalse(HashFunctions.VerifyByHashWithSalt(data, hash2));
        }