Chibuzo
Chibuzo

Reputation: 6117

PHP Mcrypt error: Cannot open source device

I downgraded to PHP 5.2.8 from PHP 5.4.2 for a reason, I enabled the mcrypt extension, but when I run the function mcrypt_create_iv ($size, MCRYPT_DEV_RANDOM), it doesn't execute properly, and I get the following warning

Warning: mcrypt_create_iv() [function.mcrypt-create-iv]:Cannot open source device

Please how do I fix this issue? Thanks for any suggestion.

Upvotes: 1

Views: 4270

Answers (3)

Alex
Alex

Reputation: 1295

Check the device file (if Linux):

/dev/random

Upvotes: 0

Chibuzo
Chibuzo

Reputation: 6117

The issue occurred because MCRYPT_DEV_URANDOM was only supported on Windows as from PHP version 5.3.0, that is why it was working well until the downgrade.

I changed to MCRYPT_RAND which worked on previous versions and the problem was solved.

Upvotes: 3

Chris
Chris

Reputation: 4368

Locate the file includes/CryptRandom.php. Find the following line (probably around line 285): $iv = mcrypt_create_iv( $rem, MCRYPT_DEV_URANDOM ); Change it to: $iv = mcrypt_create_iv( $rem, MCRYPT_RAND );

Source

Upvotes: 1

Related Questions