Maison  >  Article  >  développement back-end  >  php生成强密码的程序

php生成强密码的程序

WBOY
WBOYoriginal
2016-07-25 09:04:201052parcourir
  1. /**

  2. php生成强密码
  3. linK:bbs.it-home.org 2013/3/2
  4. */
  5. $password_length = 9;
  6. function make_seed() {

  7. list($usec, $sec) = explode(’ ‘, microtime());
  8. return (float) $sec + ((float) $usec * 100000);
  9. }
  10. srand(make_seed());

  11. $alfa = “1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM”;

  12. $token = “”;
  13. for($i = 0; $i $token .= $alfa[rand(0, strlen($alfa))];
  14. }
  15. echo $token;
  16. //方法2

  17. // Create Password
  18. $totalChar = 8; // number of chars in the password
  19. $salt = “abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789″; // salt to select chars from
  20. srand((double)microtime()*1000000); // start the random generator
  21. $Spass=””; // set the inital variable
  22. for ($i=0;$i$Spass = $Spass . substr ($salt, rand() % strlen($salt), 1);
复制代码


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn