I am using C# with RHash in order to calculate the btih hashes of of file.
Currently I’m using 3 tools in order to generate the btih hash:
rhash-1.2.9-src\bindings\monowithlibrhash-1.2.9-windllrhash-1.2.9-win32command line tool- uTorrent
The problem is that every tool generates different btih signatures for the same file (the photo was taken by me, it’s royal free):
1: 2FF7858CC0A0B216C3676A807D619FA30101E45F
2: E6F07BB3C3B3B67531C84E3452980698AC1B0DAA A:\IMG_0400.JPG
3: D0B96839A14A8C45BB81AD157805AE73425998E5
For the C# hash generation I use Hasher.GetHashForFile(f.Name, HashType.BTIH); and rhash --bith in the cmd tool.
What am I doing wrong? Is there another way to calculate the btih?
The difference between the first two is that, according to the
RHashsource code,BTIHhashes requires additional data to be correctly computed.The
init_btih_datafunction incalc_sums.cis documented with:In
test_hashes.c, theBTIHexamples are actually treated differently depending on whetherUSE_BTIH_WITH_TEST_FILENAMEhas been defined.That
init_btih_datafunction (which only seems to get called when running the command line application) in turn calls therhash_trasmitfunction a number of times depending on various parameters. At a minimum, it will call it twice, which probably explains the difference between the first two. It can, however, call it a number of other times, which I think explains the difference we see with uTorrent.The difficulty is that while the unmanaged DLL exposes the
rhash_trasmitfunction, the .NET bindings do not, which means that it is not possible to supply the additional data that is expected.