Tutorials Infos - Anleitungen - Hilfe - Dreamcodes
 

Password Generator

Aufruf pass(int,int,int,int) erzeugt ein zufälliges passwort mit
pass(Anzahl Kleinbuchstaben, Anz. Grossb., Anz. Zahlen, Anz. Sonderzeichen)

Code:

/*
* License: GNU-General Public License
* For details please refer to http://www.gnu.org/copyleft/gpl.txt
*
* Passwordgenerator, Hakan Kuecuekyilmaz
* Buelent Tiknaz
* gets number of[a-z],[A-Z],[0-9],[!º$%&/()=?*]
* returns STRING
* STRING pass(INT,INT,INT,INT);
*
*/

function pass($a,$A,$num,$spec) {
// initialize the random generator
srand ((double) microtime() * 10000000);

$b = array(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z);
$B = array(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z);
$NUM = array('0','1','2','3','4','5','6','7','8','9');
$SPEC = array('!','§','$','%','&','/','(',')','=','?','*');

$D = $a + $A + $num + $spec;

for ($i = 0; $i <= $a; $i++) {
$index = array_rand($b,$a);
$pass[] = ($b[$index[$i]]);

}
for ($i = 0; $i <= $A; $i++) {
$index = array_rand($B,$A);
$pass[] = ($B[$index[$i]]);

}
for ($i = 0; $i <= $num; $i++) {
$index = array_rand($NUM,$num);
$pass[] = ($NUM[$index[$i]]);

}
for ($i = 0; $i <= $a; $i++) {
$index = array_rand($SPEC,$spec);
$pass[] = ($SPEC[$index[$i]]);

}
for ($i = 0; $i <= $D; $i++) {
$index = array_rand($pass,$D);
$pass_new .= ($pass[$index[$i]]);
}
return $pass_new;


}

?>

 
ID: 118
eingestellt am: 19.03.2003
Autor: Q
Status zum lesen: Gast
gelesen: 6709
Webseite: www.dreamcodes.com
[Drucken]