Public Member Functions | |
__construct () | |
get_key ($key= '') | |
set_key ($key= '') | |
encode ($string, $key= '') | |
decode ($string, $key= '') | |
encode_from_legacy ($string, $legacy_mode=MCRYPT_MODE_ECB, $key= '') | |
_xor_encode ($string, $key) | |
_xor_decode ($string, $key) | |
_xor_merge ($string, $key) | |
mcrypt_encode ($data, $key) | |
mcrypt_decode ($data, $key) | |
_add_cipher_noise ($data, $key) | |
_remove_cipher_noise ($data, $key) | |
set_cipher ($cipher) | |
set_mode ($mode) | |
_get_cipher () | |
_get_mode () | |
set_hash ($type= 'sha1') | |
hash ($str) | |
sha1 ($str) | |
Data Fields | |
$CI | |
$encryption_key = '' | |
$_hash_type = 'sha1' | |
$_mcrypt_exists = FALSE | |
$_mcrypt_cipher | |
$_mcrypt_mode | |
__construct | ( | ) |
Constructor
Simply determines whether the mcrypt library exists.
_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
Function description
private
string | |
string |
_get_cipher | ( | ) |
Get Mcrypt cipher Value
private
_get_mode | ( | ) |
Get Mcrypt Mode Value
private
_remove_cipher_noise | ( | $data, | |
$key | |||
) |
Removes permuted noise from the IV + encrypted data, reversing _add_cipher_noise()
Function description
public
type |
_xor_decode | ( | $string, | |
$key | |||
) |
XOR Decode
Takes an encoded string and key as input and generates the plain-text original message
private
string | |
string |
_xor_encode | ( | $string, | |
$key | |||
) |
XOR Encode
Takes a plain-text string and key as input and generates an encoded bit-string using XOR
private
string | |
string |
_xor_merge | ( | $string, | |
$key | |||
) |
XOR key + string Combiner
Takes a string and key as input and computes the difference using XOR
private
string | |
string |
decode | ( | $string, | |
$key = '' |
|||
) |
Decode
Reverses the above process
public
string | |
string |
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 (if supported) 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.
public
string | the string to encode |
string | the key |
encode_from_legacy | ( | $string, | |
$legacy_mode = MCRYPT_MODE_ECB , |
|||
$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
public
string | |
int | (mcrypt mode constant) |
string |
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
public
string |
hash | ( | $str) |
Hash encode a string
public
string |
mcrypt_decode | ( | $data, | |
$key | |||
) |
Decrypt using Mcrypt
public
string | |
string |
mcrypt_encode | ( | $data, | |
$key | |||
) |
Encrypt using Mcrypt
public
string | |
string |
set_cipher | ( | $cipher) |
Set the Mcrypt Cipher
public
constant |
set_hash | ( | $type = 'sha1' ) |
Set the Hash type
public
string |
set_key | ( | $key = '' ) |
Set the encryption key
public
string |
set_mode | ( | $mode) |
Set the Mcrypt Mode
public
constant |
sha1 | ( | $str) |
Generate an SHA1 Hash
public
string |