GeCipher256 Manual

About

GeCipher256 class provides means to encrypt and decrypt data.

Warning
This class only uses a simple and insecure scrambling, see AES Manual, if security is really needed.
// This example demonstrates the encryption and decryption of a string.
Char plainText[] = "O brave new world That has such people in!";
const Int32 length = sizeof(plainText);
GePrint("Plain Text: " + String(plainText));
// Define an en-/decryption key.
const Char key[32] = { '7', 'c', '3', '0', 'e', '0', '0', 'b', 'b', '6', '2', '7', '1', '4', '9', '5' };
const Int32 keyLength = sizeof(key); // in bytes
// Initialize GeCipher256 instance.
GeCipher256 cipher;
if (!cipher.Open(key, keyLength, false))
return false;
// Encryption is in-situ.
cipher.Encrypt(plainText, length);
// Get a copy of the encrypted string, just for the purpose of displaying it on console.
Char plainTextEncoded[sizeof(plainText) + 1]; // one extra byte for null termination
CopyMem(plainText, plainTextEncoded, length);
plainTextEncoded[sizeof(plainText)] = 0; // string null termination
GePrint("Encoded Text: " + String(plainTextEncoded)); // Note: This is too simple and might only show part of the string, if the encoded string contains null bytes.
// Decryption is in-situ.
cipher.Decrypt(plainText, length);
GePrint("Decoded text: " + String((char*)plainText));
cipher.Close();

Create

A GeCipher256 instance can be created by simply defining it (e.g. as a local variable). No special allocation is needed.

Use

Encryption / Decryption

Further Reading