Welcome Guest, Not a member yet? Register   Sign In
Encrypted String Changes Every Time (very bad!)
#9

[eluser]PhxVyper[/eluser]
Hi,

Actually, after further investigation, it is NOT the init. vector function that causes the "randomization" of the encrypted string. It is the _xor_encode and _xor_decode methods within the Encrypt class.

So, I have no extended the Encrypt class to just have two new methods and I'm using the core mcrypt_encode and mcrypt_decode methods.

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
* PD_Encrypt class for custom data encryption
*/
class Pd_Encrypt extends CI_Encrypt
{

    /**
     * Encrypt and Encode String
     *
     * @param string $string
     * @param string $key
     * @return string
     */
    function pd_encode($string, $key = '')
    {
        $key = $this->get_key($key);
        $enc = $string;

        if ($this->_mcrypt_exists === TRUE)
        {
            $enc = $this->mcrypt_encode($string, $key);
        }
        return base64_encode($enc);        
    }

    /**
     * Decode and Decrypt String
     *
     * @param string $string
     * @param string $key
     * @return string
     */
    function pd_decode($string, $key = '')
    {
        $key = $this->get_key($key);
        $dec = base64_decode($string);
        
         if ($dec === FALSE)
         {
             return FALSE;
         }
        
        if ($this->_mcrypt_exists === TRUE)
        {
            $dec = $this->mcrypt_decode($dec, $key);
        }
        
        return $dec;
    }
}
?>


Messages In This Thread
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 01:08 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 01:29 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 01:50 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 02:23 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 07:38 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 08:10 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 08:12 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 08:25 PM
Encrypted String Changes Every Time (very bad!) - by El Forum - 11-17-2007, 08:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB