Skip to content

Commit

Permalink
use mt_rand() instead of rand()
Browse files Browse the repository at this point in the history
As per PHP documentation, mt_rand() is a drop-in replacement for rand() with the following advantages:
- it generates better random values (using stronger algorithm)
- it is four times faster than rand()
  • Loading branch information
skyosev committed Jun 29, 2015
1 parent 9122f02 commit 1601025
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions upload/system/helper/general.php
Expand Up @@ -6,8 +6,8 @@ function token($length = 32) {
$token = '';

for ($i = 0; $i < $length; $i++) {
$token .= $string[rand(0, strlen($string) - 1)];
$token .= $string[mt_rand(0, strlen($string) - 1)];
}

return $token;
}
}

0 comments on commit 1601025

Please sign in to comment.