Created
April 9, 2013 00:38
-
-
Save ccaglayan/5341925 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Random Password Generator | |
| function _RandomPasswordGenerator() { | |
| // Create the meta-password | |
| $sMetaPassword = ""; | |
| $CONFIG['security']['password_generator'] = array("C" => array('characters' => | |
| 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'minimum' => 4, | |
| 'maximum' => 6), "S" => array('characters' => "!@()-_=+?*^&", 'minimum' => 0, | |
| 'maximum' => 0), "N" => array('characters' => '1234567890', 'minimum' => 2, | |
| 'maximum' => 2)); | |
| $ahPasswordGenerator = $CONFIG['security']['password_generator']; | |
| foreach ($ahPasswordGenerator as $cToken => $ahPasswordSeed) | |
| $sMetaPassword .= str_repeat($cToken, rand($ahPasswordSeed['minimum'], $ahPasswordSeed['maximum'])); | |
| $sMetaPassword = str_shuffle($sMetaPassword); | |
| // Create the real password | |
| $arBuffer = array(); | |
| for ($i = 0; $i < strlen($sMetaPassword); $i++) | |
| $arBuffer[] = $ahPasswordGenerator[(string )$sMetaPassword[$i]]['characters'][rand(0, | |
| strlen($ahPasswordGenerator[$sMetaPassword[$i]]['characters']) - 1)]; | |
| return implode("", $arBuffer); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment