Page 1 of 1

SHA1-hashing question :-)

PostPosted: 27 Dec 2009 15:29
by tomtop
I'm trying to create an application that must be compatible with shareaza's SHA1 hashing - but it seems like I can't find out how shareaza makes the hash-codes :roll:

An examle:

In my library I put a acsii-file called "foobar.txt". It contains the text "foobar" and has the size of 6 bytes / octets. ShareAza hashes the file to:

RBB5P6JECYQR32PLXFR76THCQESZGKDY

When I perform a SHA1-hash of the file content ("foobar") and encode the SHA1-digest into base32 (RFC-4648 compliant) I get:

77LU7CA5EELCIY5Z57UY7YSM754C7EZF

What am I doing wrong?

Re: SHA1-hashing question :-)

PostPosted: 28 Dec 2009 20:40
by ocexyz

Re: SHA1-hashing question :-)

PostPosted: 28 Dec 2009 21:52
by tomtop

Re: SHA1-hashing question :-)

PostPosted: 30 Dec 2009 04:52
by raspopov
Use HashLib library (and HashTest as example), its part of Shareaza SVN source tree.

Re: SHA1-hashing question :-)

PostPosted: 30 Dec 2009 14:01
by tomtop

Re: SHA1-hashing question :-)

PostPosted: 30 Dec 2009 15:00
by cyko_01
does the file contain metadata or id3 tags? shareaza sometimes strips this information before hashing

Re: SHA1-hashing question :-)

PostPosted: 30 Dec 2009 15:21
by tomtop

Re: SHA1-hashing question :-)

PostPosted: 30 Dec 2009 16:58
by cyko_01
sorry, I should have ready the first post better.

Re: SHA1-hashing question :-)

PostPosted: 31 Dec 2009 02:29
by kevogod

Re: SHA1-hashing question :-)

PostPosted: 31 Dec 2009 10:02
by tomtop
Problem solved. It was a matter of reversing the bytes in the dwords of the SHA1-digest. Normally they would be aligned as (byte-numbers, most significant to least significant):

4321 4321 4321 4321 4321

They had to be reversed to (byte-numbers, least significant to most significant):

1234 1234 1234 1234 1234

In order to produce the right result :-)