Project
Back to projects
A warrior fighting on a battlefield in Dynasty Legends 2

Dynasty Legends 2 © HK TAIHE INTERACTIVE LIMITED.

Script

Dynasty Legends 2 Lua Decryptor

Turns Dynasty Legends 2's encrypted Lua files back into readable source.

Status
Available

Version 1.0.0 Last tested

SHA-256 1afddaa0f78f5532a8bed37beb042fce68760b1d9c8fefa7281d13c485e8578c

Overview


Dynasty Legends 2 stores its Lua source in encrypted .lua files. The names and directory layout are left alone, but the contents use a modified form of XXTEA that regular implementations cannot decode.

This script applies the recovered key and the round count used by the game. It accepts one script or the full game folder. A directory run recreates the same folder tree under the chosen output path.

Prerequisites


Required: Python 3.10 or later. The standard library covers everything used here.

Usage


To decrypt every Lua file below the game directory, pass the installation path followed by a separate output folder:

1
python .\dynasty_legends_2_lua_decrypt.py "D:\Steam\steamapps\common\Dynasty Legends 2" ".\decrypted-lua"

A single file works the same way:

1
python .\dynasty_legends_2_lua_decrypt.py ".\Boss_LvBu.lua" ".\Boss_LvBu.decrypted.lua"

The output must be separate from the input. This keeps the encrypted originals in place and avoids picking up newly written files during a directory run.

Compatibility


The script was checked against all 11,328 Lua files from the Steam release of Dynasty Legends 2 version 1.39.600. Every result matched the output from the game’s own DecoderBytes function and decoded as UTF-8 Lua source.

The decrypted files were also passed back through the matching encryption function. All 11,328 rebuilt files matched their originals byte for byte.