public void Test_03_Performance() { byte[] Data = new byte[80 * 1024 * 1024]; SHA3_512 H = new SHA3_512(); H.ComputeVariable(Data); }
public void Test_02_1600_bits() { SHA3_512 H = new SHA3_512(); int i = 0; H.NewState += (sender, e) => { string Expected = States1600Bits[i++].Replace(" ", string.Empty); string Actual = Hashes.BinaryToString(H.GetState()).ToUpper(); Assert.AreEqual(Expected, Actual); }; byte[] Input = new byte[200]; int j; for (j = 0; j < 200; j++) { Input[j] = 0xa3; } byte[] Digest = H.ComputeVariable(Input); string s = Hashes.BinaryToString(Digest); Assert.AreEqual("e76dfad22084a8b1467fcf2ffa58361bec7628edf5f3fdc0e4805dc48caeeca81b7c13c30adf52a3659584739a2df46be589c51ca1a4a8416df6545a1ce8ba00", s); Assert.AreEqual(States1600Bits.Length, i); }
public void Test_04_SHA3_512() { SHA3_512 H = new SHA3_512(); byte[] Digest = H.ComputeVariable(new MemoryStream(new byte[0])); string s = Hashes.BinaryToString(Digest); Assert.AreEqual("a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26", s); }
/// <summary> /// Evaluates the function on a scalar argument. /// </summary> /// <param name="Argument">Function argument.</param> /// <param name="Variables">Variables collection.</param> /// <returns>Function result.</returns> public override IElement EvaluateScalar(IElement Argument, Variables Variables) { if (!(Argument.AssociatedObjectValue is byte[] Bin)) { throw new ScriptRuntimeException("Binary data expected.", this); } SHA3_512 H = new SHA3_512(); return(new ObjectValue(H.ComputeVariable(Bin))); }
public void Test_03_1600_bits_Stream() { SHA3_512 H = new SHA3_512(); byte[] Input = new byte[200]; int j; for (j = 0; j < 200; j++) { Input[j] = 0xa3; } byte[] Digest = H.ComputeVariable(new MemoryStream(Input)); string s = Hashes.BinaryToString(Digest); Assert.AreEqual("e76dfad22084a8b1467fcf2ffa58361bec7628edf5f3fdc0e4805dc48caeeca81b7c13c30adf52a3659584739a2df46be589c51ca1a4a8416df6545a1ce8ba00", s); }
public void Test_01_0_bits() { SHA3_512 H = new SHA3_512(); int i = 0; H.NewState += (sender, e) => { string Expected = States0Bits[i++].Replace(" ", string.Empty); string Actual = Hashes.BinaryToString(H.GetState()).ToUpper(); Assert.AreEqual(Expected, Actual); }; byte[] Digest = H.ComputeVariable(new byte[0]); string s = Hashes.BinaryToString(Digest); Assert.AreEqual("a69f73cca23a9ac5c8b567dc185a756e97c982164fe25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9402c3ac558f500199d95b6d3e301758586281dcd26", s); Assert.AreEqual(States0Bits.Length, i); }
static void Main(string[] args) { TestCases tc = new TestCases(); for (int i = 0; i < 2; i++) { byte[] result = SHA3_224.ComputeHash(tc.SHA3_224[i].Input); if (CompareArrays(result, tc.SHA3_224[i].Result)) { Console.WriteLine("SHA3_224 TEST " + i + " -PASS-"); } else { Console.WriteLine("SHA3_224 TEST " + i + " *FAIL!*"); } result = SHA3_256.ComputeHash(tc.SHA3_256[i].Input); if (CompareArrays(result, tc.SHA3_256[i].Result)) { Console.WriteLine("SHA3_256 TEST " + i + " -PASS-"); } else { Console.WriteLine("SHA3_256 TEST " + i + " *FAIL!*"); } result = SHA3_384.ComputeHash(tc.SHA3_384[i].Input); if (CompareArrays(result, tc.SHA3_384[i].Result)) { Console.WriteLine("SHA3_384 TEST " + i + " -PASS-"); } else { Console.WriteLine("SHA3_384 TEST " + i + " *FAIL!*"); } result = SHA3_512.ComputeHash(tc.SHA3_512[i].Input); if (CompareArrays(result, tc.SHA3_512[i].Result)) { Console.WriteLine("SHA3_512 TEST " + i + " -PASS-"); } else { Console.WriteLine("SHA3_512 TEST " + i + " *FAIL!*"); } result = SHAKE128.ComputeHash(tc.SHAKE128[i].Input, tc.SHAKE128[i].Result.Length); if (CompareArrays(result, tc.SHAKE128[i].Result)) { Console.WriteLine("SHAKE128 TEST " + i + " -PASS-"); } else { Console.WriteLine("SHAKE128 TEST " + i + " *FAIL!*"); } result = SHAKE256.ComputeHash(tc.SHAKE256[i].Input, tc.SHAKE256[i].Result.Length); if (CompareArrays(result, tc.SHAKE256[i].Result)) { Console.WriteLine("SHAKE256 TEST " + i + " -PASS-"); } else { Console.WriteLine("SHAKE256 TEST " + i + " *FAIL!*"); } } Console.WriteLine("Press ENTER to exit..."); Console.ReadLine(); }