|
General Details
|
|
PHP (Hypertext Preprocess...
|
|
Posted 1.96 Year Ago
|
|
713 Views
|
|
Received 0 Ratings
|
|
Flexible password generator
Description
Complete password generator that fits everyone. It can return autmaticly generated passwords in lowercase, uppercase, mixed lower and uppercase, numbers and a mix of all.
Leave it with no arguments to use default setup which is a mix between lowercase, uppercase and digits. And a length of 10 characters.
Usage: $mypass = make_password();
Source Code
Comments
| Please login to post comments. |
|
|
hmm indeed some interesting reading you got there :) thanks for the comment, i'll be looking into the things you mentioned ;)
|
|
|
Not bad ;-)
My only improvement would be that you add $output = false at the start, then at the end just before the return add if ($output === false) { trigger_error('Something went wrong since a password could not be generated.', E_USER_WARNING); }
Then you can easily test to make sure a password was generated by doing using === false ;-)
The next level up would be to use OOP... then you could use constants to set letters, and add your own character set:
$password = new password();
$password->set_charset('0123456789abcdef'); //hex ;-)
or
$password->set_charset(password::CHARSET_HEX); //hex again, but this time using a constant so you cant accidentally miss a character ;-)
also, if you use the STD library you can implement the array interface allowing you to manipulate the generated password like an array:
count($password);
//get the first character
print $password[0];
Have fun.
Kind regards,
Scott
|
More "PHP (Hypertext Preprocessor)" Source Codes By This Author
Recently Posted "PHP (Hypertext Preprocessor)" Source Codes
Recently Rated "PHP (Hypertext Preprocessor)" Source Codes
|