SproutCMS

This is the code documentation for the SproutCMS project

class Encrypt

The Encrypt library provides two-way encryption of text and binary strings
using the MCrypt extension (http://php.net/mcrypt)

Source code (5 results)

/sprout/config/encryption.php   Highlighted file source

Line 18: * @package Encrypt
Line 20: * Encrypt configuration is defined in groups which allows you to easily switch
Line 21: * between different encryption settings for different uses.
Line 25: * key - Encryption key used to do encryption and decryption. The default option
Line 28: * For best security, your encryption key should be at least 16 characters
Line 30: * @note Do not use a hash as your key. This significantly lowers encryption entropy.
Line 32: * mode - MCrypt encryption mode. By default, MCRYPT_MODE_NOFB is used. This mode
Line 34: * produces the shortest encrypted output.
Line 37: * cipher - MCrypt encryption cipher. By default, the MCRYPT_RIJNDAEL_128 cipher is used.

/sprout/Helpers/Drivers/Session/Cache.php   Highlighted file source

Line 22: use Sprout\Helpers\Encrypt;
Line 41: protected $encrypt;
Line 45: // Load Encrypt library
Line 46: if (Kohana::config('session.encryption'))
Line 48: $this->encrypt = new Encrypt;
Line 88: return Kohana::config('session.encryption') ? $this->encrypt->decode($data) : $data;
Line 98: $data = Kohana::config('session.encryption') ? $this->encrypt->encode($data) : $data;

/sprout/Helpers/Drivers/Session/Database.php   Highlighted file source

Line 22: use Sprout\Helpers\Encrypt;
Line 34: // Encryption
Line 35: protected $encrypt;
Line 46: if ( ! empty($config['encryption']))
Line 48: // Load encryption
Line 49: $this->encrypt = Encrypt::instance();
Line 89: return ($this->encrypt === NULL) ? base64_decode($data) : $this->encrypt->decode($data);
Line 98: 'data' => ($this->encrypt === NULL) ? base64_encode($data) : $this->encrypt->encode($data)

/sprout/Helpers/Encrypt.php   Highlighted file source

Line 23: * The Encrypt library provides two-way encryption of text and binary strings
Line 26: class Encrypt
Line 36: * Returns a singleton instance of Encrypt.
Line 39: * @return Encrypt
Line 46: empty($instance) and $instance = new Encrypt((array) $config);
Line 52: * Loads encryption configuration and validates the data.
Line 59: if ( ! defined('MCRYPT_ENCRYPT'))
Line 60: throw new Kohana_Exception('encrypt.requires_mcrypt');
Line 67: if (($config = Kohana::config('encryption.'.$config)) === NULL)
Line 68: throw new Kohana_Exception('encrypt.undefined_group', $name);
Line 74: $config += Kohana::config('encryption.default');
Line 79: $config = Kohana::config('encryption.default');
Line 83: throw new Kohana_Exception('encrypt.no_encryption_key');
Line 102: * Encrypts a string and returns an encrypted string that can be decoded.
Line 104: * @param string data to be encrypted
Line 105: * @return string encrypted data
Line 110: if (Encrypt::$rand === NULL)
Line 115: Encrypt::$rand = MCRYPT_RAND;
Line 122: Encrypt::$rand = MCRYPT_DEV_URANDOM;
Line 127: Encrypt::$rand = MCRYPT_DEV_RANDOM;
Line 132: Encrypt::$rand = MCRYPT_RAND;
Line 137: if (Encrypt::$rand === MCRYPT_RAND)
Line 145: $iv = mcrypt_create_iv($this->config['iv_size'], Encrypt::$rand);
Line 147: // Encrypt the data using the configured options and generated iv
Line 148: $data = mcrypt_encrypt($this->config['cipher'], $this->config['key'], $data, $this->config['mode'], $iv);
Line 175: } // End Encrypt

/sprout/i18n/en_US/encrypt.php   Highlighted file source

Line 18: 'requires_mcrypt' => 'To use the Encrypt library, mcrypt must be enabled in your PHP installation',
Line 19: 'no_encryption_key' => 'To use the Encrypt library, you must set an encryption key in your config file'

A total of 52 lines in 5 files were found