Earlier on today I released a PHP password generator that I created and a few people asked for the source codes to it -- I am not releasing the FULL site, but what I will release is the function I had created to generate the functions.
Use it as you wish, I'm not bothered about credits, but it would be nice!
Function:
Usage:
Result:
Will generate a 7 digit long password consisting of numbers, lower-case and upper-case letters.
Enjoy,
m0nsta.
Use it as you wish, I'm not bothered about credits, but it would be nice!
Function:
PHP:
function GeneratePassword( $l, $s, $n, $uc, $lc )
{
/** ABOUT THE PARAMETERS
* $l - integer - length of the password to be generated
* $s - integer - include symbols in the password (VALUES: '1' or '0' -- 1=yes, 0=no)
* $n - integer - include numbers in the password (VALUES: '1' or '0' -- 1=yes, 0=no)
* $uc - integer - include upper-case characters in the password (VALUES: '1' or '0' -- 1=yes, 0=no)
* $lc - integer - include lower-case characters in the password (VALUES: '1' or '0' -- 1=yes, 0=no)
*/
$symbols = "¬!\"£$%^&*()_+{}:@~<>?`-=[];'#,./";
$numbers = "1234567890";
$upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$lower = "abcdefghijklmnopqrstuvwxyz";
$characters_to_include = "";
$password = "";
if ( $s == "1" ) $characters_to_include .= $symbols;
if ( $n == "1" ) $characters_to_include .= $numbers;
if ( $uc == "1" ) $characters_to_include .= $upper;
if ( $lc == "1" ) $characters_to_include .= $lower;
/*none selected*/
if ( !$s || !$n || !$uc || !$lc ) $characters_to_include = $numbers . $upper . $lower;
/*none selected*/
for( $p = 1; $p <= $l; $p++ )
{
$password .= substr( $characters_to_include, mt_rand( $p, strlen( $characters_to_include ) ), 1 );
}
return htmlentities( $password );
}
Usage:
PHP:
<?php
echo GeneratePassword( 7, 0, 1, 1, 1 );
?>
Result:
Will generate a 7 digit long password consisting of numbers, lower-case and upper-case letters.
Enjoy,
m0nsta.