CI_Encryption::initialize()

initialize($params) Parameters: $params (array) – Configuration parameters Returns: CI_Encryption instance (method chaining) Return type: CI_Encryption Initializes (configures) the library to use a different driver, cipher, mode or key. Example: $this->encryption->initialize( array('mode' => 'ctr') ); Please refer to the Configuring the library section for detailed info.

CI_Encryption::hkdf()

hkdf($key[, $digest = 'sha512'[, $salt = NULL[, $length = NULL[, $info = '']]]]) Parameters: $key (string) – Input key material $digest (string) – A SHA-2 family digest algorithm $salt (string) – Optional salt $length (int) – Optional output length $info (string) – Optional context/application-specific info Returns: A pseudo-random key or FALSE on failure Return type: string Derives a key from another, presumably weaker key. This method is used internally to derive an encryption

CI_Encryption::encrypt()

encrypt($data[, $params = NULL]) Parameters: $data (string) – Data to encrypt $params (array) – Optional parameters Returns: Encrypted data or FALSE on failure Return type: string Encrypts the input data and returns its ciphertext. Example: $ciphertext = $this->encryption->encrypt('My secret message'); Please refer to the Using custom parameters section for information on the optional parameters.

CI_Encryption::decrypt()

decrypt($data[, $params = NULL]) Parameters: $data (string) – Data to decrypt $params (array) – Optional parameters Returns: Decrypted data or FALSE on failure Return type: string Decrypts the input data and returns it in plain-text. Example: echo $this->encryption->decrypt($ciphertext); Please refer to the Using custom parameters secrion for information on the optional parameters.

CI_Encryption::create_key()

create_key($length) Parameters: $length (int) – Output length Returns: A pseudo-random cryptographic key with the specified length, or FALSE on failure Return type: string Creates a cryptographic key by fetching random data from the operating system’s sources (i.e. /dev/urandom).

CI_Encryption

class CI_Encryption initialize($params) Parameters: $params (array) – Configuration parameters Returns: CI_Encryption instance (method chaining) Return type: CI_Encryption Initializes (configures) the library to use a different driver, cipher, mode or key. Example: $this->encryption->initialize( array('mode' => 'ctr') ); Please refer to the Configuring the library section for detailed info. encrypt($data[, $params = NULL]) Parameters: $data (string) – Data

CI_Encrypt::set_mode()

set_mode($mode) Parameters: $mode (int) – Valid PHP MCrypt mode constant Returns: CI_Encrypt instance (method chaining) Return type: CI_Encrypt Permits you to set an Mcrypt mode. By default it uses MCRYPT_MODE_CBC. Example: $this->encrypt->set_mode(MCRYPT_MODE_CFB); Please visit php.net for a list of available modes.

CI_Encrypt::set_cipher()

set_cipher($cipher) Parameters: $cipher (int) – Valid PHP MCrypt cypher constant Returns: CI_Encrypt instance (method chaining) Return type: CI_Encrypt Permits you to set an Mcrypt cipher. By default it uses MCRYPT_RIJNDAEL_256. Example: $this->encrypt->set_cipher(MCRYPT_BLOWFISH); Please visit php.net for a list of available ciphers. If you’d like to manually test whether your server supports MCrypt you can use: echo extension_loaded('mcrypt') ? 'Yup' : 'Nope';

CI_Encrypt::encode_from_legacy()

encode_from_legacy($string[, $legacy_mode = MCRYPT_MODE_ECB[, $key = '']]) Parameters: $string (string) – String to encrypt $legacy_mode (int) – Valid PHP MCrypt cipher constant $key (string) – Encryption key Returns: Newly encrypted string Return type: string Enables you to re-encode data that was originally encrypted with CodeIgniter 1.x to be compatible with the Encrypt library in CodeIgniter 2.x. It is only necessary to use this method if you have encrypted data stored permane

CI_Encrypt::encode()

encode($string[, $key = '']) Parameters: $string (string) – Data to encrypt $key (string) – Encryption key Returns: Encrypted string Return type: string Performs the data encryption and returns it as a string. Example: $msg = 'My secret message'; $encrypted_string = $this->encrypt->encode($msg); You can optionally pass your encryption key via the second parameter if you don’t want to use the one in your config file: $msg = 'My secret message'; $key = 'super-secret-key'; $e