EFMCrypto
File and data encryption/decryption using AES-256 in CBC mode, built on Unreal's own Core AES implementation. Any string works as a key, it gets hashed into a proper 256-bit key internally. A random IV is generated on every call, so encrypting the same data twice never produces the same output.
Note: This is encryption only, there's no integrity check on the encrypted data, so it's meant for save games and local config rather than anything that needs tamper detection.
Functions
EncryptFile
Callable Encrypts a file and saves to a new location.
C++
bool EncryptFile(const FString& SourceFile, const FString& DestinationFile, const FString& Key)
| Parameter | Type | Description |
|---|---|---|
SourceFile | FString | Path to the source file |
DestinationFile | FString | Path for the encrypted output |
Key | FString | Encryption key |
Returns: true if encryption succeeded
Category: EFM|Crypto
Blueprint Node
DecryptFile
Callable Decrypts a file and saves to a new location.
C++
bool DecryptFile(const FString& SourceFile, const FString& DestinationFile, const FString& Key)
Category: EFM|Crypto
Blueprint Node
EncryptBytes
Callable Encrypts a byte array.
C++
TArray<uint8> EncryptBytes(const TArray<uint8>& Data, const FString& Key)
Category: EFM|Crypto
Blueprint Node
DecryptBytes
Callable Decrypts a byte array.
C++
TArray<uint8> DecryptBytes(const TArray<uint8>& Data, const FString& Key)
Category: EFM|Crypto
Blueprint Node
EncryptString
Callable Encrypts a string.
C++
bool EncryptString(const FString& PlainText, const FString& Key, FString& OutEncrypted)
| Parameter | Type | Direction | Description |
|---|---|---|---|
PlainText | FString | In | Text to encrypt |
Key | FString | In | Encryption key |
OutEncrypted | FString | Out | Encrypted output |
Returns: true if encryption succeeded
Category: EFM|Crypto
Blueprint Node
DecryptString
Callable Decrypts a string.
C++
bool DecryptString(const FString& EncryptedText, const FString& Key, FString& OutDecrypted)
Category: EFM|Crypto
Blueprint Node
Example
// Encrypt a save file
EncryptFile(
GetGameSavedDirectory() + "save.dat",
GetGameSavedDirectory() + "save.enc",
"MySecretKey123"
)
// Encrypt a string
Encrypted = ""
EncryptString("SensitiveData", "MySecretKey123", Encrypted)
// Store Encrypted somewhere...
// Decrypt later
Decrypted = ""
DecryptString(Encrypted, "MySecretKey123", Decrypted)
// Decrypted now contains "SensitiveData"