-
Notifications
You must be signed in to change notification settings - Fork 0
CI_Encrypt
CodeIgniter Encryption Class
Provides two-way keyed encoding using Mcrypt
- Class name: CI_Encrypt
- Namespace:
public string $encryption_key = ''
Reference to the user's encryption key
- Visibility: public
protected string $_hash_type = 'sha1'
Type of hash operation
- Visibility: protected
protected boolean $_mcrypt_exists = FALSE
Flag for the existence of mcrypt
- Visibility: protected
protected string $_mcrypt_cipher
Current cipher to be used with mcrypt
- Visibility: protected
protected integer $_mcrypt_mode
Method for encrypting/decrypting data
- Visibility: protected
void CI_Encrypt::__construct()
Initialize Encryption class
- Visibility: public
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
- $key mixed
\CI_Encrypt CI_Encrypt::set_key($key)
Set the encryption key
- Visibility: public
- $key mixed
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
- $string mixed
- $key mixed
string CI_Encrypt::decode($string, $key)
Decode
Reverses the above process
- Visibility: public
- $string mixed
- $key mixed
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
- $string mixed
- $legacy_mode mixed
- $key mixed
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
- $string mixed
- $key mixed
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
- $string mixed
- $key mixed
string CI_Encrypt::mcrypt_encode($data, $key)
Encrypt using Mcrypt
- Visibility: public
- $data mixed
- $key mixed
string CI_Encrypt::mcrypt_decode($data, $key)
Decrypt using Mcrypt
- Visibility: public
- $data mixed
- $key mixed
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
- $data mixed
- $key mixed
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
- $data string
- $key string
\CI_Encrypt CI_Encrypt::set_cipher($cipher)
Set the Mcrypt Cipher
- Visibility: public
- $cipher mixed
\CI_Encrypt CI_Encrypt::set_mode($mode)
Set the Mcrypt Mode
- Visibility: public
- $mode mixed
integer CI_Encrypt::_get_cipher()
Get Mcrypt cipher Value
- Visibility: protected
integer CI_Encrypt::_get_mode()
Get Mcrypt Mode Value
- Visibility: protected
void CI_Encrypt::set_hash($type)
Set the Hash type
- Visibility: public
- $type mixed
string CI_Encrypt::hash($str)
Hash encode a string
- Visibility: public
- $str mixed