两个产生随机密码函数:
函数一:

生成随机密码函数function randomPassword($passwordLength = 8)
生成随机密码函数{
生成随机密码函数    
$str = "abcefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
生成随机密码函数    
if($passwordLength > strlen($str))
生成随机密码函数        
$passwordLength = strlen($str);
生成随机密码函数    
if($passwordLength < 8)
生成随机密码函数        
$passwordLength = 8;
生成随机密码函数    
$start = mt_rand(1, (strlen($str- $passwordLength));
生成随机密码函数    
$string = str_shuffle($str);
生成随机密码函数    
$password = substr($string, $start, $passwordLength);
生成随机密码函数    
return($password);
生成随机密码函数}

函数二:
生成随机密码函数function randomPassword($passwordLength=8)
生成随机密码函数{
生成随机密码函数    
//密码字符串
生成随机密码函数
    define("PASS_STRING","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");    
生成随机密码函数       
生成随机密码函数    
if($passwordLength < 8)
生成随机密码函数        
$passwordLength = 8;
生成随机密码函数    
for($i = 1$i <= $passwordLength$i++)
生成随机密码函数    {
生成随机密码函数        
$randomPosition = rand(0, strlen(PASS_STRING)-1);
生成随机密码函数        
$password .= substr(PASS_STRING, $randomPosition, 1);
生成随机密码函数    }
生成随机密码函数    
return $password;
生成随机密码函数}

相关文章:

  • 2022-12-23
  • 2022-01-15
  • 2021-12-09
  • 2021-10-28
  • 2021-07-02
  • 2021-10-06
  • 2021-07-20
猜你喜欢
  • 2021-11-29
  • 2021-11-29
  • 2022-01-18
  • 2021-07-23
相关资源
相似解决方案