How to generate a random password?

Search Engine Optimization Toolkit. Graphic

How to generate a random password?

PHP Scripts



This function GenRandomPassword() generates a random password of x characters long. This function is very useful to generate a password for your new registered customers.

<?php

#This function generates a random password of x characters long.
function GenRandomPassword($lenght) { 
        
    
$str "abcdefghijkmnopqrstuvwxyz0123456789"

    
srand((double)microtime()*1000000); 
    for (
$i=0$i<$lenght$i++) {
        
$num rand() % strlen($str); 
        
$tmp substr($str$num1); 
        
$pass $pass $tmp
    }     
    return 
$pass
}

#Generate a random password of 8 characters long.
$password GenRandomPassword("8");
echo 
"You Password: ".$password

?>


Download Script


Rate: Votes: 6
Excellent! Very Good Average Fair Poor 


Google Site Search - Provided by www.seo-toolkit.com
Google
 
Web www.seo-toolkit.com
Add to Favorites   Set as Home Page     Nederlands

Fight against Spam by linking to this Anti-Spam page.