MCPcopy Create free account
hub / github.com/diasurgical/devilution / DecryptFileKey

Function DecryptFileKey

3rdParty/StormLib/src/SBaseCommon.cpp:585–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585DWORD DecryptFileKey(
586 const char * szFileName,
587 ULONGLONG MpqPos,
588 DWORD dwFileSize,
589 DWORD dwFlags)
590{
591 DWORD dwFileKey;
592 DWORD dwMpqPos = (DWORD)MpqPos;
593
594 // File key is calculated from plain name
595 szFileName = GetPlainFileName(szFileName);
596 dwFileKey = HashString(szFileName, MPQ_HASH_FILE_KEY);
597
598 // Fix the key, if needed
599 if(dwFlags & MPQ_FILE_FIX_KEY)
600 dwFileKey = (dwFileKey + dwMpqPos) ^ dwFileSize;
601
602 // Return the key
603 return dwFileKey;
604}
605
606//-----------------------------------------------------------------------------
607// Handle validation functions

Callers 1

SFileOpenFileExFunction · 0.85

Calls 2

GetPlainFileNameFunction · 0.85
HashStringFunction · 0.85

Tested by

no test coverage detected