You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 line
424B

  1. <?php
  2. namespace common\helpers;
  3. class Password {
  4. public static function generate($length = 6)
  5. {
  6. $chaine = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789' ;
  7. $nb = strlen($chaine) - 1;
  8. $code = '';
  9. for($i=0; $i < $length; $i++)
  10. {
  11. $pos = mt_rand(0, $nb);
  12. $car = $chaine[$pos];
  13. $code .= $car;
  14. }
  15. return $code ;
  16. }
  17. }