Advertisement
obernardovieira

Gerar Senha (letras e numeros)

Dec 27th, 2013
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.36 KB | None | 0 0
  1. function gerarsenha() {
  2.     $letras = "abcdefghijklmnopqrstuvwxyz";
  3.     $numeros = "0123456789";
  4.     $senha = "";
  5.     srand(time());
  6.     for ($j = 0; $j != 12; $j++) {
  7.         $bin = rand(0,1);
  8.         if($bin == 1) {
  9.             $letra = rand(0,25);
  10.             $senha = $senha.$letras[$letra];
  11.         }
  12.         else {
  13.             $numero = rand(0,9);
  14.             $senha = $senha.$numeros[$numero];
  15.         }
  16.     }
  17.     echo $senha;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement