コード例 #1
0
        public void Test_04_Performance()
        {
            byte[]   Data = new byte[80 * 1024 * 1024];
            SHA3_224 H    = new SHA3_224();

            H.ComputeVariable(Data);
        }
コード例 #2
0
        public void Test_02_1600_bits()
        {
            SHA3_224 H = new SHA3_224();
            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("9376816aba503f72f96ce7eb65ac095deee3be4bf9bbc2a1cb7e11e0", s);
            Assert.AreEqual(States1600Bits.Length, i);
        }
コード例 #3
0
ファイル: StreamTests.cs プロジェクト: robinreigns/IoTGateway
        public void Test_01_SHA3_224()
        {
            SHA3_224 H = new SHA3_224();

            byte[] Digest = H.ComputeVariable(new MemoryStream(new byte[0]));
            string s      = Hashes.BinaryToString(Digest);

            Assert.AreEqual("6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7", s);
        }
コード例 #4
0
ファイル: Sha3_224.cs プロジェクト: robinreigns/IoTGateway
        /// <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_224 H = new SHA3_224();

            return(new ObjectValue(H.ComputeVariable(Bin)));
        }
コード例 #5
0
        public void Test_03_1600_bits_Stream()
        {
            SHA3_224 H = new SHA3_224();

            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("9376816aba503f72f96ce7eb65ac095deee3be4bf9bbc2a1cb7e11e0", s);
        }
コード例 #6
0
        public void Test_01_0_bits()
        {
            SHA3_224 H = new SHA3_224();
            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("6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7", s);
            Assert.AreEqual(States0Bits.Length, i);
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: vanthaiunghoa/SHA3Managed
        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();
        }