06-10-2008, 11:24 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
|
Eyes Random String Generator
Well i put this little baby together for a project of my im working on, and thought i share it with you all.
Not the moast advanced but does what i wanted.
Thereīs room for alot of improvement i would guess.
Have fun :)
PHP Code:
function myRandomStr($passLen=16, $shakes=5)
{
// Get some letters and integers easy and quick into arrays
$smal_letters = range('a','z');
$big_letters = range('A','Z');
$integers = range('0', '9');
// merge thoose arrays above to one array
$combined = array_merge($smal_letters, $big_letters, $integers);
// shake it around abit
for($s = 0; $s < intval($shakes); ++$s)
{
shuffle($combined);
}
// find out how big the array is
$len = count($combined);
// then finaly create the string
for($i = 0; $i < intval($passLen); ++$i)
{
// Choose some random letters from the array
$salt = mt_rand(0, $len);
echo($combined[$salt]);
}
}
// Lets try a 15 char long and with 5 shakes.
myRandomStr(15, 5);
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
|
|
|
|