Trying to pack with specific AES keys

I’ve spent the last ~8 hours trying to unpack, modify, and repack a game’s pak file. I was able to successfully unpack it since I have the correct AES key. After deleting some assets, I’m trying to repack the pak with encryption, but I keep running into an error.

When I run commands like:

“C:\Program Files\Epic Games\UE_4.27\Engine\Binaries\Win64\UnrealPak.exe” “C:\Users\Owner\Downloads\FModel\Output\Exports\pakchunk0-WindowsClient.pak” -Encrypt -Create=“C:\Users\Owner\Downloads\FModel\Output\Exports\PACKME” -CryptoKeys=“C:\Users\Owner\Downloads\FModel\Output\Exports\Crypto.json”

or use a .ini file instead of JSON, I get this critical error:

LogWindows: Error: === Critical error: ===
LogWindows: Error: Assertion failed: InKeyChain.MasterEncryptionKey [File:D:/Build/++UE4/Sync/Engine/Source/Developer/PakFileUtilities/Private/PakFileUtilities.cpp] [Line: 913]

I’ve tried various .ini configurations, including:

[CryptoKeys]
+EncryptionKeys=(Guid=11111111111111111111111111111111,Key=D99AA08DD9B09117B0BCCCCC9E853CFFD6A7084A9FE38EF7F0D2188586947D14)
MasterEncryptionKey=11111111111111111111111111111111

and also simpler forms like:

[CryptoKeys]
EncryptionKey=D99AA08DD9B09117B0BCCCCC9E853CFFD6A7084A9FE38EF7F0D2188586947D14

I’ve tried all variations in between as well.

The error persists, or if I provide the key directly on the command line, UnrealPak ignores it and uses a dummy AES key instead.

Any help or insight into how to correctly set up the encryption keys for repacking would be greatly appreciated. Thank you!