Classes

Class AesCrypt() Professional

Class function of the AesCrypt class

Description

The AesCrypt class provides the interface for AES encryption/decryption. Its role is to provide a cryptographic implementation of AES, the Advanced Encryption Standard as announced by NIST, effective May 26 2002. It is derived from the class CryptProvider. This class is not yet documented because it is an abstract, which cannot be instantiated.

AES uses the Rijndael algorithm to encrypt/decrypt data. It is a block code.

The current implementation supports a block length of 16 byte, and key lengths of 128, 192 or 256 bit.

SecureKey():destroy() can be called right after setting the key object, either after :new() or :setKey().

Class methods
:new()
Creates an instance of the AesCrypt class.
Methods
:encrypt()
Encrypts a buffer using a key.
:decrypt()
Decrypts a previously encrypted buffer using a key.
:prepareBuffer()
Prepares a buffer for encryption.
:setKey()
Provides a key used for encryption or decryption.
Examples
AesCrypt handling
// In this example, AesCrypt() is used 
// to encrypt a single buffer 

#include "crypt.ch" 

PROCEDURE MAIN(cBuffer) 
   LOCAL oAes 
   LOCAL oKey 
   LOCAL cResult 

   // generate a key and print out 
   oKey := SecureKey():generate() 
   ? oKey:toString() 

   // create AesCrypt()-instance using the key 
   oAes := AesCrypt():new(oKey) 

   // destroy key value 
   oKey:destroy() 

   // prepare input buffer length 
   oAes:prepareBuffer(@cBuffer)       
   
   // encrypt buffer 
   cResult := oAes:encrypt(cBuffer) 
   ? cResult 
   
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.