public
__construct
(mixed $key, mixed $strength = 128, mixed $mode = 'cbc', mixed $priority = 'openssl')
/**
* Initialise the AES encryption object.
*
* 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).
*
* @param string $key The encryption key (password). It can be a raw key (16 bytes) or a passphrase.
* @param int $strength Bit strength (128, 192 or 256) – ALWAYS USE 128 BITS. THIS PARAMETER IS DEPRECATED.
* @param string $mode Encryption mode. Can be ebc or cbc. We recommend using cbc.
* @param string $priority Priority which adapter we should try first
*/
public function __construct($key, $strength = 128, $mode = 'cbc', $priority = 'openssl')
{
if ($priority === 'openssl') {
$this->adapter = new OpenSSL();
if (!$this->adapter->isSupported()) {
$this->adapter = new Mcrypt();
}
} else {
$this->adapter = new Mcrypt();
if (!$this->adapter->isSupported()) {
$this->adapter = new OpenSSL();
}
}
$this->adapter->setEncryptionMode($mode, $strength);
$this->setPassword($key, true);
}