note 42781 deleted from function.rand by tomsommer

From: Date: Sat, 10 Jul 2004 00:36:21 +0000
Subject: note 42781 deleted from function.rand by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-72957@lists.php.net to get a copy of this message
Note Submitter: bob@rawkstar.net ---- Yet another random password generator, but this one creates readable/pronounceable passwords... <?php function randompass() { $rand_pass = ''; // makes sure the $pass var is empty. for( $j = 0; $j < 3; $j++ ) { $startnend = array( 'b','c','d','f','g','h','j','k','l','m','n', 'p','q','r','s','t','v','w','x','y','z', ); $mid = array( 'a','e','i','o','u','y', ); $count1 = count( $startnend ) - 1; $count2 = count( $mid ) - 1; for( $i = 0; $i < 3; $i++) { if( $i != 1 ) { $rand_pass .= $startnend[rand( 0, $count1 )]; } else { $rand_pass .= $mid[rand( 0, $count2 )]; } } } return $rand_pass; } $rand_pass = randompass(); echo '<p>pass: <strong>' . $rand_pass . '</strong></p>'; echo '<p>md5: <strong>' . md5( $rand_pass ) . '</strong></p>'; ?> Some examples are:- pohyerdib kibkudjam fizvoszeb jyshevram Easy to remember (since it's basically 3, 3 letter words) I've put a y in the list of vowels since it works well as a middle letter in the 3 letter words. This is excellent for a random password generator for a 'forgot password' type function.

« previous php.notes (#72957) next »