| 345 | // Calculates a Jenkin's Encrypting and decrypting MPQ file data |
| 346 | |
| 347 | ULONGLONG HashStringJenkins(const char * szFileName) |
| 348 | { |
| 349 | LPBYTE pbFileName = (LPBYTE)szFileName; |
| 350 | char szNameBuff[0x108]; |
| 351 | size_t nLength = 0; |
| 352 | unsigned int primary_hash = 1; |
| 353 | unsigned int secondary_hash = 2; |
| 354 | |
| 355 | // Normalize the file name - convert to uppercase, and convert "/" to "\\". |
| 356 | if(pbFileName != NULL) |
| 357 | { |
| 358 | char * szNamePtr = szNameBuff; |
| 359 | char * szNameEnd = szNamePtr + sizeof(szNameBuff); |
| 360 | |
| 361 | // Normalize the file name. Doesn't have to be zero terminated for hashing |
| 362 | while(szNamePtr < szNameEnd && pbFileName[0] != 0) |
| 363 | *szNamePtr++ = (char)AsciiToLowerTable[*pbFileName++]; |
| 364 | nLength = szNamePtr - szNameBuff; |
| 365 | } |
| 366 | |
| 367 | // Thanks Quantam for finding out what the algorithm is. |
| 368 | // I am really getting old for reversing large chunks of assembly |
| 369 | // that does hashing :-) |
| 370 | hashlittle2(szNameBuff, nLength, &secondary_hash, &primary_hash); |
| 371 | |
| 372 | // Combine those 2 together |
| 373 | return ((ULONGLONG)primary_hash << 0x20) | (ULONGLONG)secondary_hash; |
| 374 | } |
| 375 | #endif |
| 376 | |
| 377 | //----------------------------------------------------------------------------- |
no outgoing calls
no test coverage detected