PureAES library

Overview

This is a Purebasic 4.6x user library.

It provides two functions to encrypt/decrypt data using the AES algorithm.
AES-256 is used for encryption and SHA-256 for key generation.

Note : since version 4.40, purebasic has genuine AES functions.

Functions

PureAES_Encrypt(*Buffer, *BufferLen.Long, EncryptionKey.s)
Encrypts a memory buffer with a password.

Parameters :

Input :
*Buffer : pointer to the input buffer (to encrypt)
*BufferLen : pointer to a variable containing the input buffer length
EncryptionKey : encryption key (mandatory)

Output :
*BufferLen : pointer to a variable containing the ouput buffer length

Returned value :
#Null : encryption failed
Else : address to output buffer (encrypted)
PureAES_Decrypt(*Buffer, *BufferLen.Long, EncryptionKey.s)
Decrypts a memory buffer.

Parameters :

Input :
*Buffer : pointer to the input buffer (to decrypt)
*BufferLen : pointer to a variable containing the input buffer length
EncryptionKey : encryption key (mandatory)

Output :
*BufferLen : pointer to a variable containing the ouput buffer length

Returned value :
#Null : decryption failed
Else : address to output buffer (decrypted)
PureAES_FreeBuffer(*Memory)
Free memory allocated by PureAES functions PureAES_Encrypt() and PureAES_Decrypt().