AESFile Manual


The class AESFile provides means to create and work with AES encrypted files. Derived from BaseFile working with AES files works exactly the same as with other files, with the only exception of opening the file. So it is recommended to read BaseFile Manual first.

// This example demonstrates encrypting a file and comparing the encrypted result with the original file.
// Let user choose a file to encrypt.
Filename fnInput;
if (!fnInput.FileSelect(FILESELECTTYPE_ANYTHING, FILESELECT_LOAD, "Open file to encrypt..."))
return false;
if (!fileInput || !fileAes)
return false;
// Open the input file.
GePrint("Error: Failed to open input file.");
return false;
Filename fnAes = fnInput;
// Note: Password needs to be either 16, 24, or 32 characters long.
const char pw[] = { 's', 'p', 'e', 'a', 'k', ',', ' ', 'f', 'r', 'i', 'e', 'n', 'd', ',', ' ', 'a', 'n', 'd', ' ', 'e', 'n', 't', 'e', 'r' };
const Int32 keylen = sizeof(pw) * 8; // keylen is in bits
DebugAssert((keylen == 128) || (keylen == 192) || (keylen == 256));
const Int32 blocksize = 256;
if (!fileAes->Open(fnAes, pw, keylen, blocksize, 0, FILEOPEN_WRITE))
GePrint("Error: Failed to open AES file for writing.");
return false;
const Int fileSize = fileInput->GetLength();
Char* buffer = NewMemClear(Char, fileSize);
const Int readBytes = fileInput->TryReadBytes(buffer, fileSize);
if (readBytes != fileSize)
GePrint("Error: Failed to read data from input file.");
return false;
if (!fileAes->WriteBytes(buffer, fileSize))
GePrint("Error: Failed to write data to AES file.");
return false;
// Finally check the encryption result.
if (AESFile::CheckEncryption(fnAes, fnInput, pw, keylen, blocksize))
GePrint("Success: The encrypted file matches the encrypted version.");
GePrint("Error: The encrypted file does not match the encrypted version.");


AESFile objects are created with the usual tools, see Entity Creation and Destruction Manual.


For a plugin to be cross platform then the type and creator parameters must be correctly filled for Mac.


Further Reading