1.AES.h文件中定义key
#pragma once
#define AES_BLOCK_SIZE 16
#define AES_KEY "sample" // 定义加密的字符串,用的时候替换sample
struct CORE_API FAES
{
2.UnrealPak.cpp 中设置加密为true
void ProcessCommandLine(int32 ArgC, TCHAR* ArgV[], TArray<FPakInputPair>& Entries, FPakCommandLineParameters& CmdLineParameters)
{
...
...
Input.bNeedsCompression |= bCompress;
Input.bNeedEncryption |= bEncrypt;
Input.bNeedEncryption = true; // 强制性使用加密
UE_LOG(LogPakFile, Log, TEXT("Added file Source: %s Dest: %s"), *Input.Source, *Input.Dest);
Entries.Add(Input);
...
...
}
官方版本默认是没有定义AES_KEY的,或者如果其他UE4定义的AES_KEY和你不一样,则在使用unrealpak解压项目资源时,程序会直接崩溃。
参考 https://answers.unrealengine.com/questions/316029/protect-pak-file-from-unpack.html