Mod Encryption
Estimated reading time: 2 minutesModLoader provides a content protection framework based on libsodium since v2.1.0 for Mods that need protection.
How It Works
Encrypted Mods use ModLoader’s SideLazyLoad support:
- The encrypted Mod is a normal Mod that runs in the
earlyloadstage - During earlyload it asks the user for the decryption password (via SweetAlert2Mod dialog)
- It decrypts the real Mod data with that password
- It releases the decrypted Mod as a lazily-loaded Mod for ModLoader to load
Related APIs
SideLazyLoad API
Introduced in v2.0.0 for Mod encryption. The decryption logic in earlyload injects the decrypted Mod zip into ModLoader’s load queue via this API.
During earlyload, ModLoader repeatedly calls tryInitWaitingLazyLoadMod() to pick up new lazy-loaded Mods and load them immediately.
Reference Implementations
CryptoI18nMod
CryptoI18nMod is the v2.0.0 encryption demo, using the i18n Mod as a full example.
SimpleCryptWrapper
SimpleCryptWrapper is a simple tool that wraps another Mod so it requires a decryption password on load. Mainly for protecting image assets.
Dependencies
Encrypted Mods typically depend on:
- SweetAlert2Mod — Provides dialogs for password input
- libsodium — Cryptography library for encryption/decryption
Notes
Mod encryption offers basic protection and cannot stop technically skilled users from bypassing it. It is mainly for preventing casual copying and redistribution of protected content (e.g. beauty images).
