PHP Warning: mcrypt_decrypt(): Module initialization failed in

Hello,

PHP Warning: mcrypt_decrypt(): Module initialization failed in

can cause this error? I’m using php 5.4.28

[php]
class Hash {

protected $key;     // Secret Key to secure hashed password
protected $etype;   // Encryption Algorithm
protected $mcmod;   // Mcrypt Mod
protected $rand;    // Mcrypt Random Number generator
protected $iv;      // Mcrypt initialization vector

public function __construct()
{
    $this->etype = MCRYPT_RIJNDAEL_256;
    $this->mcmod = MCRYPT_MODE_ECB;
    $this->rand  = MCRYPT_RAND;
    $this->key   = 'C2jNZ2--#xZ';
    $this->iv    = @mcrypt_create_iv(@mcrypt_get_iv_size($this->etype, $this->mcmod), $this->rand);

    if(!function_exists('mcrypt_create_iv'))
    {
        exit('<strong>HASH Error:</strong> Class needs Mcrypt library to work.');
    }

    if(version_compare(PHP_VERSION, '5.3.0') === -1)
    {
        exit('<strong>HASH Error:</strong> Class needs at least PHP 5.3.0 to work.');
    }
}

public function make($password, $key = FALSE)
{
    return trim(bin2hex(mcrypt_encrypt($this->etype, $this->key($key), $password, $this->mcmod, $this->iv)));
}

public function take($protected, $key = FALSE)
{
    return trim(mcrypt_decrypt($this->etype, $this->key($key), hex2bin($protected), $this->mcmod, $this->iv));
}

public function key($key)
{
    return strlen($key) == 32 ? $key : $this->key;
}

}
[/php]

Error line: return trim(mcrypt_decrypt($this->etype, $this->key($key), hex2bin($protected), $this->mcmod, $this->iv));

Note: No problem at localhost

Best Regards

It means that the function is either not installed or installed wrong. Add php_info() to the top of a php page and run it, see if the module is enabled.

Well, in your code, you check to see if the function exists. But, it is called mcrypt_decrypt_iv !!!
So, you check to see if the function exists, but, then you call a different function name?

Sounds like you have the incorrect name for the function. OR, inside the mcrypt_decrpt_iv function,
there is supposed to be a sub-function that is called mcrypt_decrypt and you are not passing the
correct arguments to it.

I would check inside the mcrypt_decrypt_iv function code and see what is needed for arguments.

Sponsor our Newsletter | Privacy Policy | Terms of Service