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') :
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
string
The encryption key (password). It can be a raw key (16 bytes) or a passphrase.- strength
int
Bit strength (128, 192 or 256) – ALWAYS USE 128 BITS. THIS PARAMETER IS DEPRECATED.- mode
string
Encryption mode. Can be ebc or cbc. We recommend using cbc.- priority
string
Priority which adapter we should try first
Response
mixed
decryptString
Decrypts a ciphertext into a plaintext string using AES
decryptString( stringToDecrypt, base64encoded = true) :
Arguments
- stringToDecrypt
string
The ciphertext to decrypt. The first 16 bytes of the raw string must contain the IV (initialisation vector).- base64encoded
bool
Should I Base64-decode the data before decryption?
Response
string
The plain text string
encryptString
Encrypts a string using AES
encryptString( stringToEncrypt, base64encoded = true) :
Arguments
- stringToEncrypt
string
The plaintext to encrypt- base64encoded
bool
Should I Base64-encode the result?
Response
string
The 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
int
Blocksize to process- iv
string
IV
Response
string
isSupported
Is AES encryption supported by this PHP installation?
isSupported() :
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
string
The password (either user-provided password or binary encryption key) to use- legacyMode
bool
True to use the legacy key expansion. We recommend against using it.
Response
void
Properties
key
The cipher key.
Type(s)
string