Aes

A simple implementation of AES-128, AES-192 and AES-256 encryption using the high performance mcrypt library.

since

1.0

package

Joomla CMS

Methods

__construct

Initialise the AES encryption object.

__construct( key,  strength = 128,  mode = 'cbc',  priority = 'openssl') : 
deprecated

Note: If the key is not 16 bytes this class will do a stupid key expansion for legacy reasons (produce the SHA-256 of the key string and throw away half of it).

deprecated

4.3 $strength will be removed in 6.0

Arguments

key

stringThe encryption key (password). It can be a raw key (16 bytes) or a passphrase.

strength

intBit strength (128, 192 or 256) – ALWAYS USE 128 BITS. THIS PARAMETER IS DEPRECATED.

mode

stringEncryption mode. Can be ebc or cbc. We recommend using cbc.

priority

stringPriority which adapter we should try first

Response

mixed

decryptString

Decrypts a ciphertext into a plaintext string using AES

decryptString( stringToDecrypt,  base64encoded = true) : 

Arguments

stringToDecrypt

stringThe ciphertext to decrypt. The first 16 bytes of the raw string must contain the IV (initialisation vector).

base64encoded

boolShould I Base64-decode the data before decryption?

Response

stringThe plain text string

encryptString

Encrypts a string using AES

encryptString( stringToEncrypt,  base64encoded = true) : 

Arguments

stringToEncrypt

stringThe plaintext to encrypt

base64encoded

boolShould I Base64-encode the result?

Response

stringThe cryptotext. Please note that the first 16 bytes of the raw string is the IV (initialisation vector) which is necessary for decoding the string.

getExpandedKey

Get the expanded key

getExpandedKey( blockSize,  iv) : 

Arguments

blockSize

intBlocksize to process

iv

stringIV

Response

string

isSupported

Is AES encryption supported by this PHP installation?

isSupported() : 
static

Response

bool

setPassword

Sets the password for this instance.

setPassword( password,  legacyMode = false) : 

WARNING: Do not use the legacy mode, it's insecure

since

4.0.0

Arguments

password

stringThe password (either user-provided password or binary encryption key) to use

legacyMode

boolTrue to use the legacy key expansion. We recommend against using it.

Response

void

Properties

key

The cipher key.

Type(s)

string

adapter

The AES encryption adapter in use.

Type(s)

AesInterface