Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]jak wygenerować nowe hasło
robos85
post
Post #1





Grupa: Zarejestrowani
Postów: 466
Pomógł: 11
Dołączył: 21.09.2006
Skąd: Szczecin

Ostrzeżenie: (0%)
-----


Jak wygenerować nowe hasło składające się z cyfr i małych i dużych liter.
np. 8 znakowe?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
pyro
post
Post #2





Grupa: Zarejestrowani
Postów: 2 148
Pomógł: 230
Dołączył: 26.03.2008

Ostrzeżenie: (0%)
-----


  1. <?php
  2. function new_password($chars_number)
  3. {
  4. // napisałem ci funkcje ;D
  5. if($chars_number == 0)
  6. {
  7. return 0;
  8. }
  9. $callback_string = '';
  10. $low_letters = range('a', 'z');
  11. $big_letters = range('A', 'Z');
  12. $numbers = range(0, 9);
  13. $what = array(1,2,3);
  14. for($i = 0; $i < $chars_number; $i++)
  15. {
  16. shuffle($what);
  17. if($what == 1)
  18. {
  19. shuffle($low_letters);
  20. $callback_string .= $low_letters[0];
  21. }
  22. elseif($what == 2)
  23. {
  24. shuffle($big_letters);
  25. $callback_string .= $big_letters[0];
  26. }
  27. else
  28. {
  29. shuffle($numbers);
  30. $callback_string .= $numbers[0];
  31. }
  32. }
  33. return $callback_string;
  34. }
  35. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 16.10.2025 - 13:01