SWD Technical Solutions - Atlantic Franchise Swellendam



Home arrow SMS Make Text BiggerMake Text SmallerReset Text Size
Contact Us - ADSL - Hosting - Domains - Sign up - Live Help

Creating random passwords

<?
function Random_Password($length) {
    
srand(date("s"));
    
$possible_charactors "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
$string "";
    while(
strlen($string)<$length) {
        
$string .= substr($possible_charactorsrand()%(strlen($possible_charactors))),1);
    }
    return(
$string);
}
echo 
Random_Password(8);
?>


A good Random Pronounceable Password Generator can be done like this:
<?
function genpassword($length){ 

    
srand((double)microtime()*1000000); 
     
    
$vowels = array("a""e""i""o""u"); 
    
$cons = array("b""c""d""g""h""j""k""l""m""n""p""r""s""t""u""v""w""tr"
    
"cr""br""fr""th""dr""ch""ph""wr""st""sp""sw""pr""sl""cl"); 
     
    
$num_vowels count($vowels); 
    
$num_cons count($cons); 
     
    for(
$i 0$i $length$i++){ 
        
$password .= $cons[rand(0$num_cons 1)] . $vowels[rand(0$num_vowels 1)]; 
    } 
     
    return 
substr($password0$length); 

?>


Usage to create a 10 char password: include("genpassword.function") 
echo genpassword(10);


 
Tag it:
Delicious
Furl it!
Spurl
digg
Blinkbits
BlinkList
blogmarks
co.mments
connotea
De.lirio.us
digg
Fark
feedmelinks
LinkaGoGo
Ma.gnolia
Netvouz
NewsVine
RawSugar
Reddit
Shadows
Simpy
Smarking
TailRank
Wists
YahooMyWeb
< Prev   Next >
Related Items

Joomla Template by Chris Bruce - Fatboys Team