equal
deleted
inserted
replaced
742 * @param int $return_encoding optional - can be ENC_BINARY, ENC_HEX or ENC_BASE64 |
742 * @param int $return_encoding optional - can be ENC_BINARY, ENC_HEX or ENC_BASE64 |
743 */ |
743 */ |
744 |
744 |
745 function encrypt($text, $key, $return_encoding = ENC_HEX) |
745 function encrypt($text, $key, $return_encoding = ENC_HEX) |
746 { |
746 { |
|
747 if ( $text == '' ) |
|
748 return ''; |
747 if ( $this->mcrypt && $this->blockSizeInBits == mcrypt_module_get_algo_block_size(eval('return MCRYPT_RIJNDAEL_'.$this->keySizeInBits.';')) ) |
749 if ( $this->mcrypt && $this->blockSizeInBits == mcrypt_module_get_algo_block_size(eval('return MCRYPT_RIJNDAEL_'.$this->keySizeInBits.';')) ) |
748 { |
750 { |
749 $iv_size = mcrypt_get_iv_size($this->mcrypt, MCRYPT_MODE_ECB); |
751 $iv_size = mcrypt_get_iv_size($this->mcrypt, MCRYPT_MODE_ECB); |
750 $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
752 $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); |
751 $cryptext = mcrypt_encrypt($this->mcrypt, $key, $text, MCRYPT_MODE_ECB, $iv); |
753 $cryptext = mcrypt_encrypt($this->mcrypt, $key, $text, MCRYPT_MODE_ECB, $iv); |
798 * @return string |
800 * @return string |
799 */ |
801 */ |
800 |
802 |
801 function decrypt($text, $key, $input_encoding = ENC_HEX) |
803 function decrypt($text, $key, $input_encoding = ENC_HEX) |
802 { |
804 { |
|
805 if ( $text == '' ) |
|
806 return ''; |
803 switch($input_encoding) |
807 switch($input_encoding) |
804 { |
808 { |
805 case ENC_BINARY: |
809 case ENC_BINARY: |
806 default: |
810 default: |
807 break; |
811 break; |
995 while ($n <= -2147483649) $n += 4294967296; |
999 while ($n <= -2147483649) $n += 4294967296; |
996 return (int)$n; |
1000 return (int)$n; |
997 } |
1001 } |
998 |
1002 |
999 function encrypt($str, $key) { |
1003 function encrypt($str, $key) { |
1000 if ($str == "") { |
1004 if ($str == "") |
|
1005 { |
1001 return ""; |
1006 return ""; |
1002 } |
1007 } |
1003 $v = $this->str2long($str, true); |
1008 $v = $this->str2long($str, true); |
1004 $k = $this->str2long($key, false); |
1009 $k = $this->str2long($key, false); |
1005 if (count($k) < 4) { |
1010 if (count($k) < 4) { |