Random: return empty string if $length is 0

This commit is contained in:
terrafrost 2017-12-03 22:39:01 -06:00
parent 703f7840db
commit ab5158dcd3

View File

@ -67,6 +67,10 @@ if (!function_exists('crypt_random_string')) {
*/
function crypt_random_string($length)
{
if (!$length) {
return '';
}
if (CRYPT_RANDOM_IS_WINDOWS) {
// method 1. prior to PHP 5.3, mcrypt_create_iv() would call rand() on windows
if (extension_loaded('mcrypt') && version_compare(PHP_VERSION, '5.3.0', '>=')) {