开发者

MCRYPT_DEV_RANDOM always the same

开发者 https://www.devze.com 2023-01-06 18:04 出处:网络
I\'m using MCRYPT_DEV_RAND开发者_JAVA技巧OM 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, bu

I'm using MCRYPT_DEV_RAND开发者_JAVA技巧OM 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?


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消