MCRYPT_DEV_RANDOM always the same

I'm using MCRYPT_DEV_RANDOM and MCRYPT_DEV_URANDOM as part of blowfish encryption, but I'm noticing it outputs the same random digit every time. It differs from machine to machine, but it's the same in each machine.

  • Is this normal?
  • Does it affect the strength of the initialization vector (IV) I generate with it?

Answers


I'm guessing that you're using Windows and that your PHP version is older than 5.3

http://php.net/manual/en/function.mcrypt-create-iv.php: PHP 5.3.0: "MCRYPT_DEV_RANDOM and MCRYPT_DEV_URANDOM became available on Windows platforms."

To answer your questions:

  • Is this normal? It is a known condition for older PHP versions in Windows. Otherwise, no.
  • Does it affect the strength of the initialization vector (IV) I generate with it? Yes, it does. Your IVs MUST be unique for each encryption.

Need Your Help

Recommendation for automated test suite package structure for Selenium testing across multiple broswers

unit-testing selenium testing automated-tests package-structuring

So, I could use a recommendation or two on what makes the most sense on how to structure my automated test package (it's java based using Selenium 2.4.5).