I need to generate a salt (to pass to crypt) but the server doesn't have mcrypt (and I do not have the ability to put it there). Is there a way I can do it with openssl_random_pseudo_bytes
or another built-in PHP function?
It is important that it has safe-randomness.
My mcrypt was:
$salt = "$" . $algorithm . "$" . $length . "$";
$salt .= substr( str_replace( "+", ".", base64_encode( mcrypt_create_iv( 128, MCRYPT_DEV_URANDOM ) ) ), 0, 22 );
return $salt;
How would I do this without mcrypt?