Monster Hunter PSP games (MHP2G, MHFU, MHP3rd) use encryption on various data files. The mhef (Monster Hunter Encryption Functions) library provides tools to decrypt and encrypt these files.
| File Type | Description | Encryption |
|---|---|---|
| DATA.BIN | Main game archive | Data cipher |
| Quest files (.mib) | Quest definitions | Quest cipher |
| Save data | Player saves | Save cipher |
| DLC files | Downloaded content | DLC cipher |
Used for the main DATA.BIN archive:
from mhef.psp import DataCipher
# Game-specific cipher
cipher = DataCipher(DataCipher.MHP2G) # For MHFU/MHP2G
# cipher = DataCipher(DataCipher.MHP3) # For MHP3rd
# Decrypt
with open('DATA.BIN', 'rb') as f:
encrypted = f.read()
decrypted = cipher.decrypt(encrypted)
# Encrypt
encrypted = cipher.encrypt(decrypted)Used for quest/mission files:
from mhef.psp import QuestCipher
cipher = QuestCipher(QuestCipher.MHP2G)
# Decrypt quest file
decrypted = cipher.decrypt(encrypted_quest)
# Encrypt quest file
encrypted = cipher.encrypt(decrypted_quest)Used for save game data:
from mhef.psp import SaveCipher
cipher = SaveCipher(SaveCipher.MHP2G)
# Decrypt save
decrypted = cipher.decrypt(encrypted_save)
# Encrypt save
encrypted = cipher.encrypt(decrypted_save)Used for downloaded content:
from mhef.psp import DLCCipher
cipher = DLCCipher(DLCCipher.MHP2G)
# Decrypt DLC
decrypted = cipher.decrypt(encrypted_dlc)
# Encrypt DLC
encrypted = cipher.encrypt(decrypted_dlc)The encryption uses a combination of:
- XOR operations with key tables
- Byte shuffling/permutation
- Block-based processing
The key tables are derived from game-specific seeds and vary by:
- Game version (MHP2G vs MHP3)
- File type (data vs quest vs save)
- Region (JP vs NA vs EU)
# Pseudocode for key table generation
def generate_key_table(seed, size):
table = bytearray(size)
state = seed
for i in range(size):
state = (state * MULTIPLIER + INCREMENT) & 0xFFFFFFFF
table[i] = (state >> 16) & 0xFF
return tableDifferent game regions may use different encryption keys:
| Game | Region | Notes |
|---|---|---|
| MHP2G | JP | Original Japanese release |
| MHFU | NA | North American release |
| MHFU | EU | European release |
FUComplete handles cross-region saves by supporting all key variants.
mhef includes command-line tools:
# Decrypt DATA.BIN
python -m mhef.psp.data decrypt MHP2G DATA.BIN DATA_decrypted.BIN
# Encrypt DATA.BIN
python -m mhef.psp.data encrypt MHP2G DATA_decrypted.BIN DATA.BIN
# Decrypt quest
python -m mhef.psp.quest decrypt MHP2G quest.mib quest_decrypted.mib- Extract ISO to get DATA.BIN
- Decrypt DATA.BIN using mhef
- Modify files
- Re-encrypt DATA.BIN
- Replace in ISO
Used after encryption to replace DATA.BIN in the ISO without full rebuild.
mhef requires:
- Python 3.x
- PyCrypto or PyCryptodome
pip install pycryptodome
pip install mhef- mhef library: https://github.com/svanheulen/mhef
- GitLab mirror: https://gitlab.com/svanheulen/mhef