Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   Gnucleus (Windows) (https://www.gnutellaforums.com/gnucleus-windows/)
-   -   Gnucleus SHA1 Hash strings (https://www.gnutellaforums.com/gnucleus-windows/12124-gnucleus-sha1-hash-strings.html)

Eoin June 5th, 2002 07:52 AM

Gnucleus SHA1 Hash strings
 
The gnucleus Hash string has me stumped.

Heres one for example
CZN3GPMKNMABB3W7QFAGS575PWPHX4OZ

Its 32 characters in lenght, it seems to be made up of letters A-Z however I've only ever noticed digits 2-7.

That gives a total 32 distinct characters, which would be 5 bits each. This also fits in with the size 5 dwords : 160 bits divided by 5 gives 32; the number of characters.

But I've don't know if this is right, and if it is how does it order the characters, I'd guess ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 but God only knows.

You see my problem is that I've written a hashing algo but I compare its hashs to gnucleus' until I figure out how gnuclues converts the 160 bit string to ascii.

Does anyone have any ideas.

Thanks guys.

Unregistered June 5th, 2002 02:46 PM

This may be a stupid answer, but... can't you just look at the source?

Eoin June 5th, 2002 06:43 PM

No its not a stupid answer, WinCVS wouldn't run and I couldn't find the source. That was then, this is now and I've since found it.
Code:

// Convert 5 Bytes to 8 Bytes Base32
void _Sha1toBase32(BYTE *out, const BYTE *in)
{
        const char *Table = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";

        out[0] = Table[((in[0] >> 3)              ) & 0x1F];
        out[1] = Table[((in[0] << 2) | (in[1] >> 6)) & 0x1F];
        out[2] = Table[((in[1] >> 1)              ) & 0x1F];
        out[3] = Table[((in[1] << 4) | (in[2] >> 4)) & 0x1F];
        out[4] = Table[((in[2] << 1) | (in[3] >> 7)) & 0x1F];
        out[5] = Table[((in[3] >> 2)              ) & 0x1F];
        out[6] = Table[((in[3] << 3) | (in[4] >> 5)) & 0x1F];
        out[7] = Table[((in[4]    )              ) & 0x1F];
}

// Return a base32 representation of a sha1 hash
CString Sha1toBase32(const BYTE *Sha1)
{
        char Base32[32];
        CString ret;

        _Sha1toBase32((BYTE *)Base32, Sha1);
        _Sha1toBase32((BYTE *)Base32 + 8, Sha1 + 5);
        _Sha1toBase32((BYTE *)Base32 + 16, Sha1 + 10);
        _Sha1toBase32((BYTE *)Base32 + 24, Sha1 + 15);

        ret = CString(Base32, 32);
        return ret;
}

I still can't get this bloody thing to work though, :confused: I'll figre it out.


All times are GMT -7. The time now is 10:37 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.