Cryptography


Description


The cryptography class enables to you encrypt/decrypt data using either Mcrypt or OpenSSL.


Methods


factory([string $name = null])


The factory method returns a cryptography object. If you want to get an instance of any of the other cryptography configurations defined in the config file then you'll have to pass the configuration name as the first argument to the factory method.


// Returns instance of the "default" cryptography configuration defined in the config file

$crypto = Crypto::factory();

// Returns instance of the "openssl" cryptography configuration defined in the config file

$crypto = Crypto::factory('openssl');

encrypt(string $string)


Encrypting data is done using the encrypt method.


$encrypted = $crypto->encrypt('foobar');

// You can also use the magic schortcut to the default configuration

$encrypted = Crypto::encrypt('foobar');

decrypt(string $string)


Decrypting data is done using the decrypt method.


$decrypted = $crypto->decrypt($encrypted);

// You can also use the magic schortcut to the default configuration

$decrypted = Crypto::decrypt($encrypted);