From c4abab033a488c78d673e7a1973aa2284259fa6a Mon Sep 17 00:00:00 2001 From: Greg MacLellan Date: Sat, 5 Jan 2019 18:00:22 -0500 Subject: [PATCH] Update Sha tests to use test constants and UTF8 strings --- NetCoreExtensions.Tests/HashTests.cs | 40 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/NetCoreExtensions.Tests/HashTests.cs b/NetCoreExtensions.Tests/HashTests.cs index 71fe7de..f6a6550 100644 --- a/NetCoreExtensions.Tests/HashTests.cs +++ b/NetCoreExtensions.Tests/HashTests.cs @@ -15,7 +15,7 @@ public class HashTests [Fact] public void Sha1_ByteArray() { - new byte[] { 0, 1, 2 }.Sha1() + TestDataBytes.Sha1() .ToString() .ShouldBe("0c7a623fd2bbc05b06423be359e4021d36e721ad"); } @@ -23,23 +23,23 @@ public void Sha1_ByteArray() [Fact] public void Sha1_String() { - "test1".Sha1() + TestDataString.Sha1() .ToString() - .ShouldBe("b444ac06613fc8d63795be9ad0beaf55011936ac"); + .ShouldBe("1a973e72d9c7350b287c8862f0444392748aa483"); } [Fact] public void Sha1_String_ASCII() { - "test2".Sha1(Encoding.ASCII) + TestDataString.Sha1(Encoding.ASCII) .ToString() - .ShouldBe("109f4b3c50d7b0df729d299bc6f8e9ef9066971f"); + .ShouldBe("aae64a5c2190fbd17e4ac6766026fac7c0ea04ed"); } [Fact] public void Sha256_ByteArray() { - new byte[] { 0, 1, 2 }.Sha256() + TestDataBytes.Sha256() .ToString() .ShouldBe("ae4b3280e56e2faf83f414a6e3dabe9d5fbe18976544c05fed121accb85b53fc"); } @@ -47,23 +47,23 @@ public void Sha256_ByteArray() [Fact] public void Sha256_String() { - "test1".Sha256() + TestDataString.Sha256() .ToString() - .ShouldBe("1b4f0e9851971998e732078544c96b36c3d01cedf7caa332359d6f1d83567014"); + .ShouldBe("9650bd8769e9daea0faa46ac10321aed56ee2a3d5e68b62b3face9a8d7d909f3"); } [Fact] public void Sha256_String_ASCII() { - "test2".Sha256(Encoding.ASCII) + TestDataString.Sha256(Encoding.ASCII) .ToString() - .ShouldBe("60303ae22b998861bce3b28f33eec1be758a213c86c93c076dbe9f558c11c752"); + .ShouldBe("0702db534bbfcd9bbb4dc3ada64a714e0f1ae5c836a7299533d0803086668a3e"); } [Fact] public void Sha384_ByteArray() { - new byte[] { 0, 1, 2 }.Sha384() + TestDataBytes.Sha384() .ToString() .ShouldBe("4f895854c1a4fc5aa2e0456eaf8d0ecaa70c196bd901153861d76b8fa3cd95ceea29eab6a279f8b08437703ce0b4b91a"); } @@ -71,23 +71,23 @@ public void Sha384_ByteArray() [Fact] public void Sha384_String() { - "test1".Sha384() + TestDataString.Sha384() .ToString() - .ShouldBe("44accf4a6221d01de386da6d2c48b0fae47930c80d2371cd669bff5235c6c1a5ce47f863a1379829f8602822f96410c2"); + .ShouldBe("feaa9e0e4440f97ecb880b74c629dc43eb2bbef81df346b2c86c57e0d790169d5773bb48b4d204fad8bea922bb537037"); } [Fact] public void Sha384_String_ASCII() { - "test2".Sha384(Encoding.ASCII) + TestDataString.Sha384(Encoding.ASCII) .ToString() - .ShouldBe("96fd02f78758ae9d418feb871df005460fada2b6a0a83b731842fcf5ce717490413423a18e8806bfde10f132d153367b"); + .ShouldBe("6f02eb26f9f34277d3833d8501657eb07f2cb56b3ec2dfe8e9f26829ea4b1cc53750049b15968447f316b66ac7a5a9fb"); } [Fact] public void Sha512_ByteArray() { - new byte[] { 0, 1, 2 }.Sha512() + TestDataBytes.Sha512() .ToString() .ShouldBe("8081da5f9c1e3d0e1aa16f604d5e5064543cff5d7bace2bb312252461e151b3fe0f034ea8dc1dacff3361a892d625fbe1b614cda265f87a473c24b0fa1d91dfd"); } @@ -95,17 +95,17 @@ public void Sha512_ByteArray() [Fact] public void Sha512_String() { - "test1".Sha512() + TestDataString.Sha512() .ToString() - .ShouldBe("b16ed7d24b3ecbd4164dcdad374e08c0ab7518aa07f9d3683f34c2b3c67a15830268cb4a56c1ff6f54c8e54a795f5b87c08668b51f82d0093f7baee7d2981181"); + .ShouldBe("f7ae28bc327c9669693958446d105400f28815ec417e418aeda6535b064b0e400fdf46e81935be984aae9fd63ad0b5bfdbb7d53be6c199a5a445a60af58319db"); } [Fact] public void Sha512_String_ASCII() { - "test2".Sha512(Encoding.ASCII) + TestDataString.Sha512(Encoding.ASCII) .ToString() - .ShouldBe("6d201beeefb589b08ef0672dac82353d0cbd9ad99e1642c83a1601f3d647bcca003257b5e8f31bdc1d73fbec84fb085c79d6e2677b7ff927e823a54e789140d9"); + .ShouldBe("701f88dac3fe016b0eb2b2a0a9b5981fa93940e8f494776cd70155a1d1159bc6e630802aede5115ac833e735ed4aeb89335d54d6f3de7ede10ec99feacdecf0e"); } [Fact]