Developers.Hash.TigerTree.File

From Shareaza Wiki
Revision as of 18:26, 31 December 2007 by Dirtycat (talk | contribs) (Importing page from Tikiwiki)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

TigerTree on the test file

The test file is 4 KB. The first 1 KB is 1024 ASCII 'a' characters. The remaining kilobytes are composed of 1024 'b', then 'c', and then 'd' characters.

<source lang="c"> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb... cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc... dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd... </source>

I wrote this code that opens a file and reads it into a CBuffer object.

<source lang="c"> // Takes a path to a file // Opens it, and reads its contents into the given buffer void FileToBuffer(LPCTSTR path, CBuffer* buffer) {

// Open the file and get its size HANDLE file = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); DWORD size = GetFileSize(file, NULL);

// Prepare that much room in the buffer, and read the file into the buffer buffer->EnsureBuffer(size); ReadFile(file, buffer->m_pBuffer, size, &size, NULL); buffer->m_nLength += size;

// Close the file CloseHandle(file); } </source>

From there, I can hand a pointer and size to HashData. The results are:

<source lang="c"> tigerbase16a 3fb43cb709b04173088b8c4dfafeb3ad1267b01cef2fd61b donkeybase16a 55c9c9098f3fce13d16593cdd5487bad </source>


look into the CTigerTree and CED2K objects in more detail figure out how to get the whole trees be able to do the 4 leaf hashes be able to do intermediate hashes, and manually build the tree up the root hash confirm that you get the same root hash as above