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()); } }
public void TestDoubleHashCheckSumOfHexInput() { var hexTestVectors = new Dictionary <string, string> { { string.Empty, "5df6e0e2" }, { "616263", "4f8b42c2" }, { "6162636462636465636465666465666765666768666768696768696a68696a6b696a6b6c6a6b6c6d6b6c6d6e6c6d6e6f6d6e6f706e6f7071", "0cffe17f" }, { "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f67", "6d377950" }, { "54686520717569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f672e", "a51a910e" }, }; foreach (var testString in hexTestVectors) { var hashBytes = SHA256.DoubleHashCheckSum(testString.Key); Assert.AreEqual(testString.Value, hashBytes.ToHex()); } }