UE4 文件加密

记录:

文件的加密和解密代码:

FString aa = "This is a test";
    uint8* Blob1; //we declere uint8 pointer
    uint32 Size1; //for size calculation
    Size1 = aa.Len();
    Size1 = Size1 + (FAES::AESBlockSize - (Size1 % FAES::AESBlockSize));
    Blob1 = new uint8[Size1];
    const TCHAR* KeyChars = AirLineBackNS::AirLinePrivateKey.GetCharArray().GetData();  
    StringToBytes(aa, Blob1, Size1);
    FAES::EncryptData(Blob1, Size1, TCHAR_TO_ANSI(KeyChars));

    FString bb = FString::FromHexBlob(Blob1, Size1);    
    uint8* Blob2; //we declere uint8 pointer
    uint32 Size2; //for size calculation
    Size2 = bb.Len();
    Size2 = Size2 - (FAES::AESBlockSize - (Size2 % FAES::AESBlockSize));
    Blob2 = new uint8[Size2];
    FString::ToHexBlob(bb,Blob2, Size2);
    FAES::DecryptData(Blob2, Size2, TCHAR_TO_ANSI(KeyChars));
    FString cc = BytesToString(Blob2, Size2);

    UE_LOG(LogTemp, Error, TEXT("Deserial %s"), *aa);
    UE_LOG(LogTemp, Error, TEXT("Deserial %s"), *bb);
    UE_LOG(LogTemp, Error, TEXT("Deserial %s"), *cc);

头文件

#include “Misc/AES.h”
#include “Misc/Paths.h”

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页