summaryrefslogtreecommitdiffstats
path: root/system/libraries/Encrypt.php
diff options
context:
space:
mode:
authorIban Eguia <admin@razican.com>2012-06-08 23:01:31 +0200
committerIban Eguia <admin@razican.com>2012-06-08 23:01:31 +0200
commit895e98c0f04f1087e8900ce8423ad3210a423770 (patch)
tree6adfe487293df38807084599f1f04157b5531e54 /system/libraries/Encrypt.php
parent0ed4f63f4268b0c98f549ffd711702fd45a761d0 (diff)
parenta593c69de4ea125c096f611c78dd0839489e7ebd (diff)
Merge remote-tracking branch 'upstream/develop' into new_date
Diffstat (limited to 'system/libraries/Encrypt.php')
-rw-r--r--system/libraries/Encrypt.php73
1 files changed, 54 insertions, 19 deletions
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index b29eb470e..ce5e030b0 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -38,15 +38,49 @@
*/
class CI_Encrypt {
- public $encryption_key = '';
- protected $_hash_type = 'sha1';
- protected $_mcrypt_exists = FALSE;
+ /**
+ * Reference to the user's encryption key
+ *
+ * @var string
+ */
+ public $encryption_key = '';
+
+ /**
+ * Type of hash operation
+ *
+ * @var string
+ */
+ protected $_hash_type = 'sha1';
+
+ /**
+ * Flag for the existance of mcrypt
+ *
+ * @var bool
+ */
+ protected $_mcrypt_exists = FALSE;
+
+ /**
+ * Current cipher to be used with mcrypt
+ *
+ * @var string
+ */
protected $_mcrypt_cipher;
+
+ /**
+ * Method for encrypting/decrypting data
+ *
+ * @var int
+ */
protected $_mcrypt_mode;
+ /**
+ * Initialize Encryption class
+ *
+ * @return void
+ */
public function __construct()
{
- $this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
+ $this->_mcrypt_exists = function_exists('mcrypt_encrypt');
log_message('debug', 'Encrypt Class Initialized');
}
@@ -63,15 +97,14 @@ class CI_Encrypt {
*/
public function get_key($key = '')
{
- if ($key == '')
+ if ($key === '')
{
- if ($this->encryption_key != '')
+ if ($this->encryption_key !== '')
{
return $this->encryption_key;
}
- $CI =& get_instance();
- $key = $CI->config->item('encryption_key');
+ $key = config_item('encryption_key');
if ($key === FALSE)
{
@@ -349,8 +382,9 @@ class CI_Encrypt {
*
* Function description
*
- * @param type
- * @return type
+ * @param string $data
+ * @param string $key
+ * @return string
*/
protected function _remove_cipher_noise($data, $key)
{
@@ -382,8 +416,8 @@ class CI_Encrypt {
/**
* Set the Mcrypt Cipher
*
- * @param constant
- * @return string
+ * @param int
+ * @return object
*/
public function set_cipher($cipher)
{
@@ -396,8 +430,8 @@ class CI_Encrypt {
/**
* Set the Mcrypt Mode
*
- * @param constant
- * @return string
+ * @param int
+ * @return object
*/
public function set_mode($mode)
{
@@ -410,11 +444,11 @@ class CI_Encrypt {
/**
* Get Mcrypt cipher Value
*
- * @return string
+ * @return int
*/
protected function _get_cipher()
{
- if ($this->_mcrypt_cipher == '')
+ if ($this->_mcrypt_cipher === NULL)
{
return $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
}
@@ -427,11 +461,11 @@ class CI_Encrypt {
/**
* Get Mcrypt Mode Value
*
- * @return string
+ * @return int
*/
protected function _get_mode()
{
- if ($this->_mcrypt_mode == '')
+ if ($this->_mcrypt_mode === NULL)
{
return $this->_mcrypt_mode = MCRYPT_MODE_CBC;
}
@@ -464,7 +498,8 @@ class CI_Encrypt {
{
return ($this->_hash_type === 'sha1') ? sha1($str) : md5($str);
}
+
}
/* End of file Encrypt.php */
-/* Location: ./system/libraries/Encrypt.php */
+/* Location: ./system/libraries/Encrypt.php */ \ No newline at end of file