Zend - The PHP Company




Passwords

Add Code


Easy Password Generation  

Type: code fragment
Added by: leosha
Entered: 14/01/2001
Last modified: 08/12/2006
Rating: - (fewer than 3 votes)
Views: 10053
Very easy password generation (2 example)


<? 
srand
((double)microtime()*1000000); 
$characters "a,b,c,d,e,f,1,2,3,4,5,A,B,C,D,E,F";    
// symbols where are allowed in the password
$characters_length = (strlen($characters)-1)/2;         $token explode(",",$characters);                     
  
$pass_length=8;   // length of the password
  
for($i=0;$i<$pass_length;$i++) {                      
    
$rand rand(0,$characters_length);               
    
$password.= $token[$rand];                        


echo 
"$password"
?> 


<? 
srand
((double)microtime()*1000000); 
$token md5(uniqid(rand()));  

$password  substr($token03); 
$password .= substr($token52); 
$password .= substr($token, -3); 

echo 
"$password"
?> 






Usage Example




Rate This Script





Search



This Category All Categories