PHP Password Generator 08-24-2013, 06:38 PM
#1
Hi! Made this little script as a practice.
Code:
<?php
function rand_password($len)
{
mt_srand((double)microtime()*1000000^getmypid());
$password='';
$chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+@#?~'; // Used characters
while(strlen($password)<$len)
$password.=substr($chars,(mt_rand()%strlen($chars)),1);
return $password;
}
$password=rand_password($num);
?>
<html>
<body>
<title> Password Generator </title>
<form method="GET" action="pass.php">
How long password you want:<input type="text" size="60" name="num">
<input type="submit" value="[ ok ]"><br>
</form>
<?php
echo "Generated password: <b>$password</b>";
?>
![[+]](https://sinister.li/images/modern/collapse_collapsed.png)


![[Image: Z8KDe.png]](http://i.imgur.com/Z8KDe.png)