Show DevBest Random Password generator.

Hindi

System.out.println(" ");
Dec 30, 2012
989
193
Since I was bored and had nothing to do really, I thought I should do something and code something. I ended up coding this simple password generator script.

Honestly its quite simple nothing complex.

So create two files.

First one : Index.php

PHP:
<?php
include ("init.php");
?>
<html>
    <head>
            <title> Random Password Generator </title>
    </head>
    <body>  
        <center>
              
                <br />
            <p>
                    Your random Password : <?php echo random_string(10); ?>
              
                <br /><br /><br />

            </p>
        </center>
    </body>
    <footer>
            <center><i>    Script written by Hades (Mr H) </i></center>
</html>

And second file would be : init.php
PHP:
<?php

function random_string($length){
    $charset = array_merge(range('a','z'), range('A','Z'), range('1','9'));
  
    shuffle($charset); // shuffles all characters randomly
  
    $password = array_slice($charset, 0, $length);
  
    return implode('',$password);
}

?>

If you edit the echo random_string(10) in index.php, It'll change the size of password, like (20) etc.

It uses one function which includes the range of the characters & numbers, shuffles the character set and yeah. enjoy.
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
To be fair this didn't need to be in 2 files and could've been done with only a couple lines of php and don't even need to implode function ;p

But nice method.
 

Hindi

System.out.println(" ");
Dec 30, 2012
989
193
To be fair this didn't need to be in 2 files and could've been done with only a couple lines of php and don't even need to implode function ;p

But nice method.
What method would you use, instead of imploding the function and thank you! :D
 

Zodiak

recovering crack addict
Nov 18, 2011
453
417
PHP:
<?php

$random = ''.rand(9,999).''.substr(sha1(time()).''.rand(9,9999999).''.rand(9,9999999),0,33);

echo $random;

?>
Easier method:p nice method though:)
 

Users who are viewing this thread

Top