^Status|Draft|
^Todo|Check styling consistent, Proofread|
====== Encrypt Library ======
===== Overview =====
The Encrypt Library provides an easy way to encrypt and decrypt data using symmetric keys.
You can choose what cypher you'd like the algorithm to use and you can specify your own key for the encryption.
===== Loading the encryption library =====
The Encryption class is loaded into your controller by making a new instance of the Encrypt class:
$this->encrypt=new Encrypt;
Access to the library is available through $this->encrypt
===== Configuration =====
Configuration is done in ''application/config/encryption.php'' if it's not there take the one from ''system/config'' and copy it.
$config['key'] = 'YOUR CYPHER KEY';
$config['mode'] = MCRYPT_MODE_NOFB;
$config['cipher'] = MCRYPT_RIJNDAEL_128;
''config['key']'' sets the key used for encryption. It should be at least 16 characters long and contain letters, numbers, and symbols.
''$config['mode']'' the MCrypt encryption mode to use. See [[http://php.net/mcrypt]] for more information, but you probably won't need to change this.
''$config['cipher']'' sets the cipher to be used for encryption.
===== Methods =====
==== encode($data) ====
''$this->encrypt->encode($data)'' returns an encrypted version of ''$data'' using the cipher and key specified in the configuration file.
$encrypted_text = $this->encrypt->encode('The Answer is 42');
echo $encrypted_text;
==== decode($encrypted) ====
''$this->encrypt->decode($encrypted)'' returns a decrypted version of ''$encrypted'' using the cipher and key specified in the configuration file.
$encrypted_text = $this->encrypt->encode('The Answer is 42');
echo $this->encrypt->decode($encrypted_text);