Quick Search:
 
 PHP Code: Pronouncable password generator Jump to:  
Category: >> PHP Code >> Pronouncable password generator  

<< lastnext >>

Snippet Name: Pronouncable password generator

Description: Password generation function for PHP. It allows the developer to customize the password: set its length and strength. Just include this function anywhere in your code and then use it.

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: February 27th, 2009

<?PHP
 
FUNCTION generatePassword($length=9, $strength=0) {
    $vowels = 'aeuy';
    $consonants = 'bdghjmnpqrstvz';
    IF ($strength & 1) {
        $consonants .= 'BDGHJLMNPQRSTVWXZ';
    }
    IF ($strength & 2) {
        $vowels .= "AEUY";
    }
    IF ($strength & 4) {
        $consonants .= '23456789';
    }
    IF ($strength & 8) {
        $consonants .= '@#$%';
    }
 
    $password = '';
    $alt = TIME() % 2;
    FOR ($i = 0; $i < $length; $i++) {
        IF ($alt == 1) {
            $password .= $consonants[(RAND() % STRLEN($consonants))];
            $alt = 0;
        } ELSE {
            $password .= $vowels[(RAND() % STRLEN($vowels))];
            $alt = 1;
        }
    }
    RETURN $password;
}
 
?>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org