Encrypt

Brain’s Encrypt class is a derivative work of CodeIgniter’s Encrypt class. Usage is similar.

Simple Encryption & Decryption

Unless you want to specify a custom encryption key, the encryption key in the container is used. Likewise, unless you specify a custom salt the encryption key in the container is used. Unless specifically set, the cipher is MCRYPT_BLOWFISH, and the mode is MCRYPT_MODE_CBC.

$name = 'wingnut';
$encrypted = Encrypt::encode( $name );
$decrypted = Encrypt::decode( $encrypted );

// wingnut
echo $decrypted;

Specify a Custom Encryption Key and/or Salt

Encrypt::set_key('bKlEOsfPFoTcCMPZbTIL4w2qU8cuQMsLtJh');
Encrypt::set_salt('m&g*#%et5SUV"YeM~XxeR}@');

$name = 'wingnut';
$encrypted = Encrypt::encode( $name );
$decrypted = Encrypt::decode( $encrypted );

// wingnut
echo $decrypted;