Expand description
This module contains the code to encrypt and decrypt data in Total War PackFiles.
The Decryptable trait provides functions to decrypt various parts of encrypted PackFiles,
including file data, file sizes, and file paths. An implementation for anything that implements
ReadBytes + Read + Seek is provided.
The Encryptable trait provides the inverse operations. An implementation for anything that
implements WriteBytes is provided.
§Encryption Scheme
Total War games use a custom encryption scheme with different keys for different parts of the PackFile:
- Index String Key: 64-byte key for decrypting file paths
- Index U32 Key:
u32key for decrypting file sizes - Data Key:
u64key for decrypting file data (combined with au32position in PFH4 and older Packs)
§Historical Context
The encryption scheme has evolved over time:
- Shogun 2 to Arena: Used older keys (now commented out in the code)
- Modern Games: Use the current key set introduced after Arena
Traits§
- Decryptable
- Trait for decrypting encrypted PackFile data.
- Encryptable
- Trait for encrypting PackFile data.