CI_Encrypt Class Reference

List of all members.

Public Member Functions

 CI_Encrypt ()
 get_key ($key= '')
 set_key ($key= '')
 encode ($string, $key= '')
 decode ($string, $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)

Public Attributes

 $CI
 $encryption_key = ''
 $_hash_type = 'sha1'
 $_mcrypt_exists = FALSE
 $_mcrypt_cipher
 $_mcrypt_mode


Member Function Documentation

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

Function description

private

Parameters:
string 
string 
Returns:
string

CI_Encrypt::_get_cipher (  ) 

Get Mcrypt cipher Value

private

Returns:
string

CI_Encrypt::_get_mode (  ) 

Get Mcrypt Mode Value

private

Returns:
string

CI_Encrypt::_remove_cipher_noise ( data,
key 
)

Removes permuted noise from the IV + encrypted data, reversing _add_cipher_noise()

Function description

public

Parameters:
type 
Returns:
type

CI_Encrypt::_xor_decode ( string,
key 
)

XOR Decode

Takes an encoded string and key as input and generates the plain-text original message

private

Parameters:
string 
string 
Returns:
string

CI_Encrypt::_xor_encode ( string,
key 
)

XOR Encode

Takes a plain-text string and key as input and generates an encoded bit-string using XOR

private

Parameters:
string 
string 
Returns:
string

CI_Encrypt::_xor_merge ( string,
key 
)

XOR key + string Combiner

Takes a string and key as input and computes the difference using XOR

private

Parameters:
string 
string 
Returns:
string

CI_Encrypt::CI_Encrypt (  ) 

Constructor

Simply determines whether the mcrypt library exists.

CI_Encrypt::decode ( string,
key = '' 
)

Decode

Reverses the above process

public

Parameters:
string 
string 
Returns:
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 (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

Parameters:
string the string to encode
string the key
Returns:
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

public

Parameters:
string 
Returns:
string

CI_Encrypt::hash ( str  ) 

Hash encode a string

public

Parameters:
string 
Returns:
string

CI_Encrypt::mcrypt_decode ( data,
key 
)

Decrypt using Mcrypt

public

Parameters:
string 
string 
Returns:
string

CI_Encrypt::mcrypt_encode ( data,
key 
)

Encrypt using Mcrypt

public

Parameters:
string 
string 
Returns:
string

CI_Encrypt::set_cipher ( cipher  ) 

Set the Mcrypt Cipher

public

Parameters:
constant 
Returns:
string

CI_Encrypt::set_hash ( type = 'sha1'  ) 

Set the Hash type

public

Parameters:
string 
Returns:
string

CI_Encrypt::set_key ( key = ''  ) 

Set the encryption key

public

Parameters:
string 
Returns:
void

CI_Encrypt::set_mode ( mode  ) 

Set the Mcrypt Mode

public

Parameters:
constant 
Returns:
string

CI_Encrypt::sha1 ( str  ) 

Generate an SHA1 Hash

public

Parameters:
string 
Returns:
string


Member Data Documentation

CI_Encrypt::$_hash_type = 'sha1'

CI_Encrypt::$_mcrypt_cipher

CI_Encrypt::$_mcrypt_exists = FALSE

CI_Encrypt::$_mcrypt_mode

CI_Encrypt::$CI

CI_Encrypt::$encryption_key = ''


The documentation for this class was generated from the following file:

Generated on Sun Nov 16 16:09:14 2008 for CodeIgniter by  doxygen 1.5.7.1