Encryption encryption on the production server and local server

Will an encrypted password using the codeigniter encryption class get the same encrypted password on two different machines? For example, I have an online production site with some host, and I have a local installation on my computer. But the passwords do not match when I restore the database from one to another.

+3
source share
4 answers

I know this is an old question, but I had the same problem and came up with it.

CodeIgniter - . , , PHP mcrypt, , , .

, mcrypt, , dev .

. , MY_Encrypt.php:

1. mcrypt , :

class MY_Encrypt extends CI_Encrypt
{
    public function __construct()
    {
        if ( ! function_exists('mcrypt_encrypt')) {
            throw new Exception("Encryption requires mcrypt PHP extension!");
        }

        parent::__construct();
    }
}

. mcrypt, :

class MY_Encrypt extends CI_Encrypt
{
    public function __construct()
    {
        parent::__construct();

        //Pretend Mcrypt doesn't exist no matter what
        $this->_mcrypt_exists = FALSE;

    }
}

, CodeIgniter .

IMHO, , . - .

+2

, , , , , :

  • libmcrypt php-mcrypt.

  • php.ini. , :/etc/php/php.ini

  • , , uncomment php.ini.

    = mcrypt.so

  • apache -, .

+1

Without seeing your code, it is impossible to say what the problem is (therefore, you have no answers yet). However, if you encrypt the string in the same way, if you use the same encryption key, it should be the same. In the CI encryption class ( see here ), you can do this in a file config.phpas follows:

$config['encryption_key'] = "YOUR KEY";
0
source

Use this in the config.php file. It will give you another key, but the result will be the same:

$config['encryption_key'] = "YOUR KEY";
0
source

Source: https://habr.com/ru/post/1781164/


All Articles