private byte[] LH(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)); }
private byte[] IH(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)); }
public static bool SelfTest() { ASCIIEncoding enc = null; byte[] hash = null; int nI = 0; string TEST_DATA = null; byte[] TEST_HASH = null; Tiger tg = null; int _Vb_t_i4_0 = 0; byte[] _Vb_t_array_0 = null; TEST_DATA = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"; _Vb_t_array_0 = new byte[] { ((byte)15), ((byte)123), ((byte)249), ((byte)161), ((byte)155), ((byte)156), ((byte)88), ((byte)242), ((byte)183), ((byte)97), ((byte)13), ((byte)247), ((byte)232), ((byte)79), ((byte)10), ((byte)195), ((byte)167), ((byte)28), ((byte)99), ((byte)30), ((byte)123), ((byte)83), ((byte)247), ((byte)142) }; TEST_HASH = _Vb_t_array_0; tg = new Tiger(); tg.Initialize(); enc = new ASCIIEncoding(); hash = tg.ComputeHash(enc.GetBytes(TEST_DATA)); if (hash.Length != TEST_HASH.Length) { return(false); } _Vb_t_i4_0 = (TEST_HASH.Length - 1); for (nI = 0; (nI <= _Vb_t_i4_0); nI++) { if (hash[nI] != TEST_HASH[nI]) { return(false); } } return(true); }