The reason why I raise this topic to become the title is, sometimes multiple users and web administrators have a trouble to create
a good password, and most of them are also looking for a password that will expect their password away from bad activities like cracking passwords with brute-force method or matching password dictionary method. Thing that I will explain here is how to create secure passwords, though as I have said before "There is no 100% safe in cyberspace." Everything has a risk of course. And to implement it all depends on your creativity in using the password generator. Now let's begin this PHP tutorial :D
The full script as follows:
// password.gen.php <?php function make_password($num_chars) { if ((is_numeric($num_chars)) && ($num_chars >= 6) && (! is_null($num_chars))) { $password = ""; $accepted_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ1234567890~!@#$%^&*+|}{:>?<"; srand(((int)((double)microtime()*1000003)) ); for ($i=1; $i<=$num_chars; $i++) { $random_number = rand(0, (strlen($accepted_chars) -1)); $password .= $accepted_chars[$random_number] ; } return $password; } else { echo "Password must be more than 6 letters"; } } ?> <html><head><title>Password Generator</title></head> <body> Your password : <br><font style='BACKGROUND-COLOR:yellow'><b> <?php echo make_password($_POST['size']); ?> </b></font><br> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="text" name="size" value="<?php echo $_POST['size']; ?>" > <input type="submit" name="submit" value="Create!!"> </form> </body> </html> |
Now i will try to explain some of the script above
if ((is_numeric ($ num_chars)) & & ($ num_chars> = 6) & & (! is_null ($ num_chars))) (
If the input entered by the user is a number / numbers and numerical characters number more than 6 digits then...
$ password = "";
$ accepted_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV WYZ1234567890 ~!@#$%^&*+|}{:>?<";
Prepare characters, numbers and special characters that will be used as a password.
srand (((int) ((double) microtime () * 1000003)));
Then do the randomization possibilities of characters, numbers, or special characters that later on took a part of the password.
for ($ i = 1; $ i <= $ num_chars; $ i + +)
(
Perform as many repetitions depending from the input numbers...
$ random_number = rand (0, (strlen ($ accepted_chars) -1))
Create a randomized selection of characters, numbers, special characters, from a collection of characters that had been prepared earlier ...
$ password .= $ accepted_chars [$ random_number];
Enter the characters one by one taken into variable $ password
)
That's all about this PHP tutorial...quite easy right? you should try it :D
If there is a question, just feel free to ask
You can download this tutorial here
1 comments:
Thanks for this useful tutorial
Post a Comment