|
|
Jul 30, PST
|
|
This article will show you how to create a random password generator script. Please read on, and comment below if you have any questions at all. The setup for this is fairly simple. The function that generates the password goes through the $characters variable and selects a random character to generate the password until the length of the desired password: <?php function randomPassword ($length = 7){ // define possible characters $characters = "abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*"; // using the for loop to add random characters to $password until $length is reached for ($y=1; $y<=$length; $y++){ //randomly selecting characters and building the password with them $randompw = rand() %strlen($characters); $temp = substr($characters, $randompw,1); $password = $password . $temp; } return $password; } echo "Generated Password: " .randomPassword(); ?> You can use this function to easily generate random passwords. Instead of calling up the function simply as randomPassword() to call up a 7-character long password, you can insert a number as a parameter to generate a password of any length. For example, randomPassword(5) or randomPassword(10) for various password lengths. Try it out for yourself. Enjoy!
| Written by: Haily, Icy | Added: Feb 11 2010 | Last Modified: Feb 11 2010 | Views: 979 | Member Comments
| ||||||||||||||||
|
Neo Crave | Enchant Me Not | FGN-Guild.com | Rabidish | Unloadeed | Blue Stapler | Moonwalked.net | RockyRoadRules | KeliJo.net | Daily Neopets | RainbowBliss | Tugboat | Guildpets | NeoWishes | Neo Nutters | Neoeditor | Gamexe.net | Dash of Color | Figmint | Hearted Kind | Skyline Designs | Darkgirl's Life | Neo-Richies | Geeks' Planet |
||||||||||||||||