Esempio n. 1
0
        /// <summary>
        /// Tests the hasher
        /// </summary>
        /// <returns>The test result</returns>
        public static bool SelfTest()
        {
            string TEST_DATA = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";

            byte[] _Vb_t_array_0 = new byte[] { 15, 123, 249, 161, 155, 156, 88, 242, 183, 97,
                                                13, 247, 232, 79, 10, 195, 167, 28, 99, 30,
                                                123, 83, 247, 142 };
            byte[] TEST_HASH = _Vb_t_array_0;
            Tiger  tg        = new Tiger();

            tg.Initialize();
            ASCIIEncoding enc = new ASCIIEncoding();

            byte[] hash = tg.ComputeHash(enc.GetBytes(TEST_DATA));
            if (hash.Length != TEST_HASH.Length)
            {
                return(false);
            }
            int _Vb_t_i4_0 = TEST_HASH.Length - 1;
            int nI;

            for (nI = 0; (nI <= _Vb_t_i4_0); nI++)
            {
                if (hash[nI] != TEST_HASH[nI])
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        private static byte[] LeafHash(byte[] Raw_Data) //leaf hash.
        {
            byte[] Data = new byte[Raw_Data.Length + 1];

            Data[0] = 0x00; //leaf hash mark.
            Raw_Data.CopyTo(Data, 1);

            //gets tiger hash value for leafs blocks.
            Tiger TG = new Tiger();

            TG.Initialize();
            return(TG.ComputeHash(Data));
        }
Esempio n. 3
0
        private static byte[] InternalHash(byte[] LeafA, byte[] LeafB) //internal hash.
        {
            byte[] Data = new byte[LeafA.Length + LeafB.Length + 1];

            Data[0] = 0x01; //internal hash mark.

            //combines two leafs.
            LeafA.CopyTo(Data, 1);
            LeafB.CopyTo(Data, LeafA.Length + 1);

            //gets tiger hash value for combined leaf hash.
            Tiger TG = new Tiger();

            TG.Initialize();
            return(TG.ComputeHash(Data));
        }