TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-10-2008, 11:24 PM   #1 (permalink)
The Acquainted
 
EyeDentify's Avatar
 
Join Date: Nov 2007
Location: Sweden
Posts: 106
Thanks: 13
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)
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:55 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design