cvs: pear /Text_Password/tests 01-text-password.phpt

From: Date: Tue, 01 Oct 2002 18:32:06 +0000
Subject: cvs: pear /Text_Password/tests 01-text-password.phpt
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-6806@lists.php.net to get a copy of this message
olivier Tue Oct 1 14:32:06 2002 EDT Modified files: /pear/Text_Password/tests 01-text-password.phpt Log: Index: pear/Text_Password/tests/01-text-password.phpt diff -u pear/Text_Password/tests/01-text-password.phpt:1.1 pear/Text_Password/tests/01-text-password.phpt:1.2 --- pear/Text_Password/tests/01-text-password.phpt:1.1 Wed Sep 4 16:01:53 2002 +++ pear/Text_Password/tests/01-text-password.phpt Tue Oct 1 14:32:04 2002 @@ -1,11 +1,50 @@ <?php error_reporting(E_ALL); -require_once "../Password.php"; +require_once '../Password.php'; -echo "\nCreating password of 10 chars....:\t"; + +function timeToBruteForce ($password, $nbr = 0, $cmbPerSeconde = 4000000) { + global $_Text_Password_nbrCharacters; + + $nbr = ($nbr == 0) ? $_Text_Password_nbrCharacters : $nbr; + $cmb = pow($nbr, strlen($password)); + $time_max = $cmb / $cmbPerSeconde; + $time_min = ($cmb / $cmbPerSeconde) / 2; + + return array('combination' => $cmb, + 'max' => $time_max, + 'min' => $time_min); +} + +echo '<pre>'; + +echo "\nCreating pronounceable password of 10 chars....:\t"; echo Text_Password::create() . "\n\n"; -echo "\nCreating 3 different passwords...:\n"; +echo "\nCreating 3 different pronounceable passwords...:\n"; print_r(Text_Password::createMultiple(3)); + +echo "\nCreating unpronounceable password of 8 chars with a,b,c as possible chars....:\t"; +echo Text_Password::create('unpronounceable', 8, 'a,b,c') . "\n\n"; + +echo "\nCreating 4 different unpronounceable passwords...:\n"; +print_r(Text_Password::createMultiple(4, 'unpronounceable')); + +echo "\nEstimated time (in sec) to brute force an unpronounceable password of 5 chars with a 4000000 combinations per second generator...:\n"; +$pass = Text_Password::create('unpronounceable', 5); +print_r(timeToBruteForce($pass)); + + + +echo Text_Password::create('unpronounceable', 8, 'numeric') . "\n\n"; +echo Text_Password::create('unpronounceable', 8, 'alphanumeric') . "\n\n"; +echo Text_Password::create('unpronounceable', 8) . "\n\n"; + +echo Text_Password::createFromLogin('olivier', 'reverse') . "\n\n"; +echo Text_Password::createFromLogin('olivier', 'increment_char', 1) . "\n\n"; +echo Text_Password::createFromLogin('olivier', 'increment_char2', 1) . "\n\n"; +echo Text_Password::createFromLogin('olivier', 'increment_char3', 1) . "\n\n"; + +echo '</pre>'; ?>

« previous php.pear.cvs (#6806) next »