コード例 #1
0
        public void TestHashOfTextInput()
        {
            var textTestVectors = new Dictionary <string, string>
            {
                { string.Empty, "9c1185a5c5e9fc54612808977ee8f548b2258d31" },
                { "a", "0bdc9d2d256b3ee9daae347be6f4dc835a467ffe" },
                { "abc", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc" },
                { "abcdefghijklmnopqrstuvwxyz", "f71c27109c692c1b56bbdceb5b9d2865b3708dbc" },
                { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "12a053384a9c0c88e405a06c27dcf49ada62eb2b" },
                { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "b0e20b6e3116640286ed3a87a5713079b21f5189" },
                { "The quick brown fox jumps over the lazy dog", "37f332f68db77bd9d7edd4969571ad671cf9dd3b" },
                { "The quick brown fox jumps over the lazy dog.", "fc850169b1f2ce72e3f8aa0aeb5ca87d6f8519c6" }
            };

            //test hex string overload.  RIPEMD160.Hash(string hexData)
            foreach (var testString in textTestVectors)
            {
                var hex       = Hex.AsciiToHex(testString.Key);
                var hashBytes = RIPEMD160.Hash(hex);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }

            //test byte array overload.  RIPEMD160.Hash(byte[] data)
            foreach (var testString in textTestVectors)
            {
                var bytes     = Encoding.UTF8.GetBytes(testString.Key);
                var hashBytes = RIPEMD160.Hash(bytes);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }
        }
コード例 #2
0
ファイル: Sha256Tests.cs プロジェクト: kaasy/KaasyBasics
        public void TestHashOfTextInput()
        {
            var textTestVectors = new Dictionary <string, string>
            {
                { string.Empty, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }, //empty string
                { "abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" },
                { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1" },
                { "The quick brown fox jumps over the lazy dog", "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592" },
                { "The quick brown fox jumps over the lazy dog.", "ef537f25c895bfa782526529a9b63d97aa631564d5d789c2b765448c8635fb6c" }
            };

            //test hex string overload.  SHA256.Hash(string hexData)
            foreach (var testString in textTestVectors)
            {
                var hex       = Hex.AsciiToHex(testString.Key);
                var hashBytes = SHA256.Hash(hex);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }

            //test byte array overload.  SHA256.Hash(byte[] data)
            foreach (var testString in textTestVectors)
            {
                var bytes     = Encoding.UTF8.GetBytes(testString.Key);
                var hashBytes = SHA256.Hash(bytes);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }
        }
コード例 #3
0
ファイル: Sha256Tests.cs プロジェクト: kaasy/KaasyBasics
        public void TestDoubleHashOfTextInput()
        {
            var textTestVectors = new Dictionary <string, string>
            {
                { string.Empty, "5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456" }, //empty string
                { "abc", "4f8b42c22dd3729b519ba6f68d2da7cc5b2d606d05daed5ad5128cc03e6c6358" },
                { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "0cffe17f68954dac3a84fb1458bd5ec99209449749b2b308b7cb55812f9563af" },
                { "The quick brown fox jumps over the lazy dog", "6d37795021e544d82b41850edf7aabab9a0ebe274e54a519840c4666f35b3937" },
                { "The quick brown fox jumps over the lazy dog.", "a51a910ecba8a599555b32133bf1829455d55fe576677b49cb561d874077385c" }
            };

            //test hex string overload.  SHA256.DoubleHash(string hexData)
            foreach (var testString in textTestVectors)
            {
                var hex       = Hex.AsciiToHex(testString.Key);
                var hashBytes = SHA256.DoubleHash(hex);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }

            //test byte array overload.  SHA256.DoubleHash(byte[] data)
            foreach (var testString in textTestVectors)
            {
                var bytes     = Encoding.UTF8.GetBytes(testString.Key);
                var hashBytes = SHA256.DoubleHash(bytes);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }
        }
コード例 #4
0
ファイル: Sha256Tests.cs プロジェクト: kaasy/KaasyBasics
        public void TestDoubleHashCheckSumOfTextInput()
        {
            var textTestVectors = new Dictionary <string, string>
            {
                { string.Empty, "5df6e0e2" },
                { "abc", "4f8b42c2" },
                { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", "0cffe17f" },
                { "The quick brown fox jumps over the lazy dog", "6d377950" },
                { "The quick brown fox jumps over the lazy dog.", "a51a910e" }
            };

            //test hex string overload.  SHA256.DoubleHash(string hexData)
            foreach (var testString in textTestVectors)
            {
                var hex       = Hex.AsciiToHex(testString.Key);
                var hashBytes = SHA256.DoubleHashCheckSum(hex);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }

            //test byte array overload.  SHA256.DoubleHash(byte[] data)
            foreach (var testString in textTestVectors)
            {
                var bytes     = Encoding.UTF8.GetBytes(testString.Key);
                var hashBytes = SHA256.DoubleHashCheckSum(bytes);
                Assert.AreEqual(testString.Value, hashBytes.ToHex());
            }
        }