Generating a salt in PHP

Posted by qster on Stack Overflow See other posts from Stack Overflow or by qster
Published on 2010-03-25T07:33:01Z Indexed on 2010/03/25 7:43 UTC
Read the original article Hit count: 832

Filed under:
|
|
|

What's the best way to generate a cryptographically secure 32 bytes salt in PHP, without depending on libraries seldom included in typical PHP installations?

After some googling I discovered that mt_rand is not considered secure enough, but I haven't found a suggestion for a replacement. One article suggested reading from /dev/random but not only this won't work on windows; it is also very slow.

I want a reasonable balance between security and speed (ie, it shouldn't take 20 seconds to generate 512 bytes, like /dev/random usually does)

© Stack Overflow or respective owner

Related posts about php

Related posts about salt