8000 Make sure our random strings are the correct length · laravel/framework@078f749 · GitHub
[go: up one dir, main page]

Skip to content

Commit 078f749

Browse files
author
Graham Campbell
committed
Make sure our random strings are the correct length
1 parent 42b3f4c commit 078f749

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Illuminate/Support/Str.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,14 @@ public static function random($length = 16)
225225
throw new RuntimeException('Unable to generate random string.');
226226
}
227227

228-
return substr(str_replace(array('/', '+', '='), '', base64_encode($bytes)), 0, $length);
228+
$string = substr(str_replace(array('/', '+', '='), '', base64_encode($bytes)), 0, $length);
229+
230+
while (($len = strlen($string)) < $length)
231+
{
232+
$string .= static::random($length - $len);
233+
}
234+
235+
return $string;
229236
}
230237

231238
/**

0 commit comments

Comments
 (0)
0