×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Vincenzo Flauto
Added: Jun 9, 2016 7:59 AM
Views: 6
Genera una nuova password in modo random
  1. public static function generatePassword($num) {
  2.                 $password = "";
  3.                 $charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  4.  
  5.                 for($i = 0; $i < $num; $i++)
  6.                 {
  7.                         $random_int = mt_rand();
  8.                         $password .= $charset[$random_int % strlen($charset)];
  9.                 }
  10.  
  11.                 return $password;
  12.         }