View Single Post
Old 06-11-2008, 12:24 AM   #1 (permalink)
EyeDentify
The Contributor
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 91
Thanks: 11
EyeDentify is on a distinguished road
Default 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(155); 
__________________
Of course the whole point of a doomsday machine, would have been lost if you keep it a secret.
EyeDentify is offline  
Reply With Quote
The Following 2 Users Say Thank You to EyeDentify For This Useful Post:
sketchMedia (06-11-2008), Village Idiot (06-11-2008)