Skip to main content

Module encryption

Module encryption 

Source
Expand description

This module contains the code to decrypt encrypted 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.

§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: u32 key for decrypting file sizes
  • Data Key: u64 key for decrypting file data

§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.