예제 #1
0
        private void ProcessLeafs()
        {
            byte[]     buffer;
            FileStream stream = new FileStream(this.Filename, FileMode.Open, FileAccess.Read);
            FileBlock  block  = this.FileParts[Convert.ToInt16(Thread.CurrentThread.Name)];
            Tiger      tiger  = new Tiger();

            byte[] dst = new byte[0x401];
            stream.Position = block.Start;
            while (stream.Position < block.End)
            {
                uint num = ((uint)stream.Position) / 0x400;
                if ((block.End - stream.Position) < 0x200000L)
                {
                    buffer = new byte[block.End - stream.Position];
                }
                else
                {
                    buffer = new byte[0x200000];
                }
                stream.Read(buffer, 0, buffer.Length);
                int num2 = buffer.Length / 0x400;
                int num3 = 0;
                while (num3 < num2)
                {
                    Buffer.BlockCopy(buffer, num3 * 0x400, dst, 1, 0x400);
                    tiger.Initialize();
                    this.TTH[0][num++] = tiger.ComputeHash(dst);
                    num3++;
                }
                if ((num3 * 0x400) < buffer.Length)
                {
                    dst    = new byte[(buffer.Length - (num2 * 0x400)) + 1];
                    dst[0] = 0;
                    Buffer.BlockCopy(buffer, num2 * 0x400, dst, 1, dst.Length - 1);
                    tiger.Initialize();
                    this.TTH[0][num++] = tiger.ComputeHash(dst);
                    dst    = new byte[0x401];
                    dst[0] = 0;
                }
            }
            buffer = null;
            dst    = null;
        }
        private byte[] LeafHash(byte[] Raw_Data)
        {
            byte[] array = new byte[Raw_Data.Length + 1];
            array[0] = 0;
            Raw_Data.CopyTo(array, 1);
            Tiger tiger = new Tiger();

            tiger.Initialize();
            return(tiger.ComputeHash(array));
        }
예제 #3
0
        private void ProcessInternalLeaf(int Level, int Index, byte[] LeafA, byte[] LeafB)
        {
            Tiger tiger = new Tiger();

            byte[] dst = new byte[(LeafA.Length + LeafB.Length) + 1];
            dst[0] = 1;
            Buffer.BlockCopy(LeafA, 0, dst, 1, LeafA.Length);
            Buffer.BlockCopy(LeafB, 0, dst, LeafA.Length + 1, LeafA.Length);
            tiger.Initialize();
            this.TTH[Level][Index] = tiger.ComputeHash(dst);
        }
        private byte[] InternalHash(byte[] LeafA, byte[] LeafB)
        {
            byte[] array = new byte[(LeafA.Length + LeafB.Length) + 1];
            array[0] = 1;
            LeafA.CopyTo(array, 1);
            LeafB.CopyTo(array, (int)(LeafA.Length + 1));
            Tiger tiger = new Tiger();

            tiger.Initialize();
            return(tiger.ComputeHash(array));
        }
예제 #5
0
        public static bool SelfTest()
        {
            ASCIIEncoding encoding = null;

            byte[] buffer = null;
            int    index  = 0;
            string s      = null;

            byte[] buffer2 = null;
            Tiger  tiger   = null;
            int    num2    = 0;

            byte[] buffer3 = null;
            s       = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
            buffer3 = new byte[] {
                15, 0x7b, 0xf9, 0xa1, 0x9b, 0x9c, 0x58, 0xf2, 0xb7, 0x61, 13, 0xf7, 0xe8, 0x4f, 10, 0xc3,
                0xa7, 0x1c, 0x63, 30, 0x7b, 0x53, 0xf7, 0x8e
            };
            buffer2 = buffer3;
            tiger   = new Tiger();
            tiger.Initialize();
            encoding = new ASCIIEncoding();
            buffer   = tiger.ComputeHash(encoding.GetBytes(s));
            if (buffer.Length != buffer2.Length)
            {
                return(false);
            }
            num2 = buffer2.Length - 1;
            for (index = 0; index <= num2; index++)
            {
                if (buffer[index] != buffer2[index])
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #6
0
 private byte[] LH(byte[] Raw_Data)
 {
     byte[] array = new byte[Raw_Data.Length + 1];
     array[0] = 0;
     Raw_Data.CopyTo(array, 1);
     Tiger tiger = new Tiger();
     tiger.Initialize();
     return tiger.ComputeHash(array);
 }
예제 #7
0
 private byte[] IH(byte[] LeafA, byte[] LeafB)
 {
     byte[] array = new byte[(LeafA.Length + LeafB.Length) + 1];
     array[0] = 1;
     LeafA.CopyTo(array, 1);
     LeafB.CopyTo(array, (int) (LeafA.Length + 1));
     Tiger tiger = new Tiger();
     tiger.Initialize();
     return tiger.ComputeHash(array);
 }
예제 #8
0
 private void ProcessLeafs()
 {
     byte[] buffer;
     FileStream stream = new FileStream(this.Filename, FileMode.Open, FileAccess.Read);
     FileBlock block = this.FileParts[Convert.ToInt16(Thread.CurrentThread.Name)];
     Tiger tiger = new Tiger();
     byte[] dst = new byte[0x401];
     stream.Position = block.Start;
     while (stream.Position < block.End)
     {
         uint num = ((uint) stream.Position) / 0x400;
         if ((block.End - stream.Position) < 0x200000L)
         {
             buffer = new byte[block.End - stream.Position];
         }
         else
         {
             buffer = new byte[0x200000];
         }
         stream.Read(buffer, 0, buffer.Length);
         int num2 = buffer.Length / 0x400;
         int num3 = 0;
         while (num3 < num2)
         {
             Buffer.BlockCopy(buffer, num3 * 0x400, dst, 1, 0x400);
             tiger.Initialize();
             this.TTH[0][num++] = tiger.ComputeHash(dst);
             num3++;
         }
         if ((num3 * 0x400) < buffer.Length)
         {
             dst = new byte[(buffer.Length - (num2 * 0x400)) + 1];
             dst[0] = 0;
             Buffer.BlockCopy(buffer, num2 * 0x400, dst, 1, dst.Length - 1);
             tiger.Initialize();
             this.TTH[0][num++] = tiger.ComputeHash(dst);
             dst = new byte[0x401];
             dst[0] = 0;
         }
     }
     buffer = null;
     dst = null;
 }
예제 #9
0
 private void ProcessInternalLeaf(int Level, int Index, byte[] LeafA, byte[] LeafB)
 {
     Tiger tiger = new Tiger();
     byte[] dst = new byte[(LeafA.Length + LeafB.Length) + 1];
     dst[0] = 1;
     Buffer.BlockCopy(LeafA, 0, dst, 1, LeafA.Length);
     Buffer.BlockCopy(LeafB, 0, dst, LeafA.Length + 1, LeafA.Length);
     tiger.Initialize();
     this.TTH[Level][Index] = tiger.ComputeHash(dst);
 }
예제 #10
0
 public static bool SelfTest()
 {
     ASCIIEncoding encoding = null;
     byte[] buffer = null;
     int index = 0;
     string s = null;
     byte[] buffer2 = null;
     Tiger tiger = null;
     int num2 = 0;
     byte[] buffer3 = null;
     s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
     buffer3 = new byte[] {
         15, 0x7b, 0xf9, 0xa1, 0x9b, 0x9c, 0x58, 0xf2, 0xb7, 0x61, 13, 0xf7, 0xe8, 0x4f, 10, 0xc3,
         0xa7, 0x1c, 0x63, 30, 0x7b, 0x53, 0xf7, 0x8e
      };
     buffer2 = buffer3;
     tiger = new Tiger();
     tiger.Initialize();
     encoding = new ASCIIEncoding();
     buffer = tiger.ComputeHash(encoding.GetBytes(s));
     if (buffer.Length != buffer2.Length)
     {
         return false;
     }
     num2 = buffer2.Length - 1;
     for (index = 0; index <= num2; index++)
     {
         if (buffer[index] != buffer2[index])
         {
             return false;
         }
     }
     return true;
 }