![]() |
|
[PHP] Random Password Generator - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: PHP (https://sinister.li/Forum-PHP) +--- Thread: [PHP] Random Password Generator (/Thread-PHP-Random-Password-Generator) |
[PHP] Random Password Generator - Ex094 - 02-11-2013 Hello guys! Well here's another of my codes. This is basically a random password generator not an advanced one but works for the purpose. PHP Code: <html>
<head>
<title>Exo94's Random Password Generator - PHP</title>
</head>
</html>
<?php
/////////////////////////////////////
//Random Pass Generator By Exo94////
//Coded by Exo94 in PHP ///////////
//http://www.gigadev.tk///////////
//hackcommunity.com//////////////
//Give Proper Credits if used!//
///////////////////////////////
//Array to store all the letters
$alpha = array('a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z');
//Array that stores the final output that is the generated password for display to the user
$output = array();
function generate() {
global $alpha, $output;
for ($i=1; $i < 10 ; $i++) {
//Generates first random letter or number from the array
$first = array_rand($alpha);
$get_one = $alpha[$first];
//Generates second random letter or number from the array
$sec = array_rand($alpha);
$get_two = $alpha[$sec];
//Generates third random letter or number from the array
$thrd = array_rand($alpha);
$get_three = $alpha[$thrd];
//Generates fourth random letter or number from the array
$fth = array_rand($alpha);
$get_four = $alpha[$fth];
//Generates fifth random letter or number from the array
$ffth = array_rand($alpha);
$get_five = $alpha[$ffth];
//Generates sixth random letter or number from the array
$sxth = array_rand($alpha);
$get_six = $alpha[$sxth];
//Stores the output of all the random generated letter into a combined form (In the array $output)
$output = $get_one . $get_two . $get_three . $get_four . $get_five . $get_six . "\n";
}
}
echo '<b>Your Generated Passwords Are:</b>';
//Generates random passwords many time (Depends upon the length of the Array list)
for ($i=0; $i < count($alpha) ; $i++) {
generate();
echo "<li>$output</li>";
}
?>The output of the script is like this: ![]() If you want to increase the length of your password add those lines to your needs in the generator function: PHP Code: $letter_no = array_rand($alpha);
$get_letter_no = $alpha[$letter_no];
To increase password strength or make it looks less familiar add more letters, symbols, numbers and combos to the array. Have fun ![]() Regards, Exo94 [PHP] Random Password Generator - Ex094 - 02-11-2013 Hello guys! Well here's another of my codes. This is basically a random password generator not an advanced one but works for the purpose. PHP Code: <html>
<head>
<title>Exo94's Random Password Generator - PHP</title>
</head>
</html>
<?php
/////////////////////////////////////
//Random Pass Generator By Exo94////
//Coded by Exo94 in PHP ///////////
//http://www.gigadev.tk///////////
//hackcommunity.com//////////////
//Give Proper Credits if used!//
///////////////////////////////
//Array to store all the letters
$alpha = array('a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z');
//Array that stores the final output that is the generated password for display to the user
$output = array();
function generate() {
global $alpha, $output;
for ($i=1; $i < 10 ; $i++) {
//Generates first random letter or number from the array
$first = array_rand($alpha);
$get_one = $alpha[$first];
//Generates second random letter or number from the array
$sec = array_rand($alpha);
$get_two = $alpha[$sec];
//Generates third random letter or number from the array
$thrd = array_rand($alpha);
$get_three = $alpha[$thrd];
//Generates fourth random letter or number from the array
$fth = array_rand($alpha);
$get_four = $alpha[$fth];
//Generates fifth random letter or number from the array
$ffth = array_rand($alpha);
$get_five = $alpha[$ffth];
//Generates sixth random letter or number from the array
$sxth = array_rand($alpha);
$get_six = $alpha[$sxth];
//Stores the output of all the random generated letter into a combined form (In the array $output)
$output = $get_one . $get_two . $get_three . $get_four . $get_five . $get_six . "\n";
}
}
echo '<b>Your Generated Passwords Are:</b>';
//Generates random passwords many time (Depends upon the length of the Array list)
for ($i=0; $i < count($alpha) ; $i++) {
generate();
echo "<li>$output</li>";
}
?>The output of the script is like this: ![]() If you want to increase the length of your password add those lines to your needs in the generator function: PHP Code: $letter_no = array_rand($alpha);
$get_letter_no = $alpha[$letter_no];
To increase password strength or make it looks less familiar add more letters, symbols, numbers and combos to the array. Have fun ![]() Regards, Exo94 RE: [PHP] Random Password Generator - LiXon - 02-11-2013 Heh, nice one. Thanks for sharing man !
RE: [PHP] Random Password Generator - LiXon - 02-11-2013 Heh, nice one. Thanks for sharing man !
RE: [PHP] Random Password Generator - Ex094 - 02-12-2013 (02-11-2013, 07:34 PM)LiXon Wrote: Heh, nice one. Thanks for sharing man ! Glad you liked mate
RE: [PHP] Random Password Generator - Ex094 - 02-12-2013 (02-11-2013, 07:34 PM)LiXon Wrote: Heh, nice one. Thanks for sharing man ! Glad you liked mate
RE: [PHP] Random Password Generator - zomgwtfbbq - 02-15-2013 There's a lot of things wrong with your code: 1- you start the php parser then send html right away, then start the php parser again(not to mention the wrong use of tags) 2- output is defined as an array, but is used as a string 3- way too much unnecessary variables, you can just connect the random chars and store in a variable 4- more but too lazy to sum more up I bet you can create the same output with less than 10 lines, if you want me to I can recode your app and make it way faster, so you might learn something. No offense btw. RE: [PHP] Random Password Generator - zomgwtfbbq - 02-15-2013 (02-15-2013, 06:19 PM)zomgwtfbbq Wrote: There's a lot of things wrong with your code: PHP Code: <?php
function Pass($iChars=8,$sCharset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"){
$iCharset = strlen($sCharset);
$sPass = "";
for($x=0;$x<intval($iChars);$x++){
$sPass .= $sCharset[mt_rand(0,($iCharset-1))];
}
return($sPass);
}
echo Pass();
?>RE: [PHP] Random Password Generator - Ex094 - 02-16-2013 (02-15-2013, 09:35 PM)zomgwtfbbq Wrote:None Taken, I'm just a beginner(02-15-2013, 06:19 PM)zomgwtfbbq Wrote: There's a lot of things wrong with your code:
|