示例#1
0
        static void GenerateHash_Salt()
        {
            var data = "P@ssw0rd";
            var salt = HashFunctions.GenerateSaltBase64();
            var hash = HashFunctions.GenerateHash(data, salt);

            Console.WriteLine(hash);

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

            Assert.IsTrue(HashFunctions.VerifyByHash(data, salt, hash));
            Assert.IsFalse(HashFunctions.VerifyByHash(data2, salt, hash));
            Assert.IsFalse(HashFunctions.VerifyByHash(data, salt2, hash));
            Assert.IsFalse(HashFunctions.VerifyByHash(data, salt, hash2));
        }