Question TTH (Tiger Tree Hash) ?

XP105

Member
Joined
Jan 19, 2010
Messages
7
Location
England, UK
Programming Experience
1-3
Hi,
I'm trying to figure out how to make a TTH (Tiger Tree Hash). Any help would that would also be much appreciated.
 
Last edited by a moderator:
Tth

Yeah, that helps for doing Tiger Tree Hashes. It's written in C#, but I'll see if I can translate into vb.NET (unless, of course, someone else has a better solution). Still need to figure out how to do ED2K Hashes though. In any case, thanks for that link.
 
Not sure if this will help, but I know (from the previously given link) that TTH is made up of Tiger Hash Algorithm and Merkle Tree (in what way, I'm not sure) and that:
"The original Tiger Hash code was taken from Tiger.Net which is written in Visual Basic.NET."
As you can see, that site is no longer there. That would have been too easy...

EDIT 2: The project doesn't seem to hash correctly. I tested it against 2 files I have, and a database, and I got conflicting results. My files aren't corrupt, as all the other hashes are correct, and the database is pretty reliable. Not sure what to make of it. Can anyone help, or is my project doomed to have no TTH compatibility?
 
Last edited:
The simplest solution here is to download ThexCS source and C# Express, in project properties change project type to Class Library and compile it. Now you can add reference to this dll in VB.Net project and use the classes without any conversions. You can actually also download the demo .exe from CP and just add reference to that.

I checked it against the test vectors listed at end of this article Tree Hash EXchange format (THEX) and the Thex class passed all four, ThexOptimized passed all but the 1024 A's test so this one seems to have a bug.
The test files can be created like this, empty file:
VB.NET:
Dim fs As IO.FileStream = IO.File.Create("tth")
fs.Close()
For 0 byte file include:
VB.NET:
fs.WriteByte(0)
For 1024 A's file (and same code for 1025) include:
VB.NET:
Dim b() As Byte = System.Text.Encoding.ASCII.GetBytes(New String("A"c, 1024))
fs.Write(b, 0, b.Length)
Using the library:
VB.NET:
Dim th As New ThexCS.Thex
Dim tth As String = ThexCS.Base32.ToBase32String(th.GetTTH("tth"))
 
Thanks a lot. The reason I wasn't getting what I wanted as a result was because I wanted the hash to be in Base16, not Base32, but as I already have a function to turn a Byte array into Base16 (just needed to sub out the ThexCS.Base32.ToBase32String() bit, and replace it with the Base16 function) I got the results I wanted, and when I checked it against my database, I got the desired result. Thanks a lot for all your help guys.
 
Back
Top