CI_Encrypt =============== CodeIgniter Encryption Class Provides two-way keyed encoding using Mcrypt * Class name: CI_Encrypt * Namespace: Properties ---------- ### $encryption_key public string $encryption_key = '' Reference to the user's encryption key * Visibility: **public** ### $_hash_type protected string $_hash_type = 'sha1' Type of hash operation * Visibility: **protected** ### $_mcrypt_exists protected boolean $_mcrypt_exists = FALSE Flag for the existence of mcrypt * Visibility: **protected** ### $_mcrypt_cipher protected string $_mcrypt_cipher Current cipher to be used with mcrypt * Visibility: **protected** ### $_mcrypt_mode protected integer $_mcrypt_mode Method for encrypting/decrypting data * Visibility: **protected** Methods ------- ### __construct void CI_Encrypt::__construct() Initialize Encryption class * Visibility: **public** ### get_key string CI_Encrypt::get_key($key) Fetch the encryption key Returns it as MD5 in order to have an exact-length 128 bit key. Mcrypt is sensitive to keys that are not the correct length * Visibility: **public** #### Arguments * $key **mixed** ### set_key \CI_Encrypt CI_Encrypt::set_key($key) Set the encryption key * Visibility: **public** #### Arguments * $key **mixed** ### encode string CI_Encrypt::encode($string, $key) Encode Encodes the message string using bitwise XOR encoding. The key is combined with a random hash, and then it too gets converted using XOR. The whole thing is then run through mcrypt using the randomized key. The end result is a double-encrypted message string that is randomized with each call to this function, even if the supplied message and key are the same. * Visibility: **public** #### Arguments * $string **mixed** * $key **mixed** ### decode string CI_Encrypt::decode($string, $key) Decode Reverses the above process * Visibility: **public** #### Arguments * $string **mixed** * $key **mixed** ### encode_from_legacy string CI_Encrypt::encode_from_legacy($string, $legacy_mode, $key) Encode from Legacy Takes an encoded string from the original Encryption class algorithms and returns a newly encoded string using the improved method added in 2.0.0 This allows for backwards compatibility and a method to transition to the new encryption algorithms. For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption * Visibility: **public** #### Arguments * $string **mixed** * $legacy_mode **mixed** * $key **mixed** ### _xor_decode string CI_Encrypt::_xor_decode($string, $key) XOR Decode Takes an encoded string and key as input and generates the plain-text original message * Visibility: **protected** #### Arguments * $string **mixed** * $key **mixed** ### _xor_merge string CI_Encrypt::_xor_merge($string, $key) XOR key + string Combiner Takes a string and key as input and computes the difference using XOR * Visibility: **protected** #### Arguments * $string **mixed** * $key **mixed** ### mcrypt_encode string CI_Encrypt::mcrypt_encode($data, $key) Encrypt using Mcrypt * Visibility: **public** #### Arguments * $data **mixed** * $key **mixed** ### mcrypt_decode string CI_Encrypt::mcrypt_decode($data, $key) Decrypt using Mcrypt * Visibility: **public** #### Arguments * $data **mixed** * $key **mixed** ### _add_cipher_noise string CI_Encrypt::_add_cipher_noise($data, $key) Adds permuted noise to the IV + encrypted data to protect against Man-in-the-middle attacks on CBC mode ciphers http://www.ciphersbyritter.com/GLOSSARY.HTM#IV * Visibility: **protected** #### Arguments * $data **mixed** * $key **mixed** ### _remove_cipher_noise string CI_Encrypt::_remove_cipher_noise(string $data, string $key) Removes permuted noise from the IV + encrypted data, reversing _add_cipher_noise() Function description * Visibility: **protected** #### Arguments * $data **string** * $key **string** ### set_cipher \CI_Encrypt CI_Encrypt::set_cipher($cipher) Set the Mcrypt Cipher * Visibility: **public** #### Arguments * $cipher **mixed** ### set_mode \CI_Encrypt CI_Encrypt::set_mode($mode) Set the Mcrypt Mode * Visibility: **public** #### Arguments * $mode **mixed** ### _get_cipher integer CI_Encrypt::_get_cipher() Get Mcrypt cipher Value * Visibility: **protected** ### _get_mode integer CI_Encrypt::_get_mode() Get Mcrypt Mode Value * Visibility: **protected** ### set_hash void CI_Encrypt::set_hash($type) Set the Hash type * Visibility: **public** #### Arguments * $type **mixed** ### hash string CI_Encrypt::hash($str) Hash encode a string * Visibility: **public** #### Arguments * $str **mixed**