I’m I missing something? I’ve read that I need to add something to my project’s Target or Build .cs files but I don’t know what that is? any help would be super appreciated!
Code used:
FString MyClass::Encrypt(FString String, FString Key) {
if (String.IsEmpty()) return String; //empty string? do nothing
uint8* Blob; //we declere uint8 pointer
uint32 Size; //for size calculation
//first we need to calculate the size of array, encrypted data will be processed in blocks so
//data size need to be aligned with block size
Size = String.Len();
Size = Size + (FAES::AESBlockSize - (Size % FAES::AESBlockSize));
Blob = new uint8[Size]; //So once we calculated size we allocating space in memory
//which we use for encryption
TCHAR* KeyTChar = Key.GetCharArray().GetData(); // ...turn key string...
ANSICHAR* KeyAnsi = (ANSICHAR*)TCHAR_TO_ANSI(KeyTChar); // ...into ANSICHAR array.
//We filling allocated space with string to process
if (FString::ToBlob(String, Blob, String.Len())) {
FAES::EncryptData(Blob, Size, KeyAnsi); //We encrypt the data
String = FString::FromHexBlob(Blob, Size); //now generate hex string of encrypted data
delete Blob; //deleting allocation for safety
return String; //and return it
}
delete Blob; //deleting allocation for safety
return ""; //If failed return empty string
}
FString MyClass::Decrypt(FString String, FString Key) {
if (String.IsEmpty()) return String; //empty string? do nothing
uint8* Blob; //we declere uint8 pointer
uint32 Size; //for size calculation
//first we need to calculate the size of array, encrypted data will be processed in blocks so
//data size need to be aligned with block size
Size = String.Len();
Size = Size + (FAES::AESBlockSize - (Size % FAES::AESBlockSize));
Blob = new uint8[Size]; //So once we calculated size we allocating space in memory
//which we use for encryption
TCHAR* KeyTChar = Key.GetCharArray().GetData(); // ...turn key string...
ANSICHAR* KeyAnsi = (ANSICHAR*)TCHAR_TO_ANSI(KeyTChar); // ...into ANSICHAR array.
//We filling allocated space with string to process
if (FString::ToHexBlob(String, Blob, String.Len())) {
FAES::DecryptData(Blob, Size, KeyAnsi); //We decrypt the data
String = FString::FromBlob(Blob, Size); //now generate string of decrypted data
delete Blob; //deleting allocation for safety
return String; //and return it
}
delete Blob; //deleting allocation for safety
return ""; //If failed return empty string
}