// This script will generate 14 Character long very secure password
function secure_pass()
{
// The total length of the password is PASS_LEN + LEVEL1_LEN + LEVEL2_LEN
$PASS_LEN = 10; // Length of basic password (a-z)
$LEVEL1_LEN = 2; // Number of level 1 characters (1-9)
$LEVEL2_LEN = 2; // Number of level 2 characters (any other)

$LEVEL0 = 'abcdefghijklmnpqrstuvwxyz'; // no security
$LEVEL1 = '123456789'; // better security
$LEVEL2 = '_-!?*:.'; // best security

srand((double)microtime()*1000200);
$password = NULL;

// Level 0 password generation
for ($i=0;$i<$PASS_LEN;$i++)
$password = $password.$LEVEL0{rand(0,strlen($LEVEL0))};

$pos = rand(0,strlen($password)-1);
$password{$pos} = strtoupper($password{$pos});

// Level 1 mix up
for ($i=0;$i<$LEVEL1_LEN;$i++)
{
$pos = rand(0,strlen($password)-1);
$password = substr($password,0,$pos).$LEVEL1{rand(0,strlen($LEVEL1)-1)}.substr($password,$pos);
}

// Level 2 mix up
for ($i=0;$i<$LEVEL2_LEN;$i++)
{
$pos = rand(0,strlen($password)-1);
$password = substr($password,0,$pos).$LEVEL2{rand(0,strlen($LEVEL2)-1)}.substr($password,$pos);
}

return $password;
}

kaynak: ordan burdan

Tags: , , , , , , , ,
Php - Secure Password Generator (scriptler, programlama, nasıl, nedir?, bedava) konusu
Benzer yazılar:
    Benzer yazı yok