GIDForums

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum > PHP Code Library
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Jan-2003, 08:04
Elmseeker's Avatar
Elmseeker Elmseeker is offline
Awaiting Email Confirmation
 
Join Date: Jan 2003
Posts: 87
Elmseeker is on a distinguished road

[Function] Random Password Generator


PHP Code:

// Name: rpass
// Version: 1.0
// Author: Elmseeker
// Description: Generates a random 6-5 character password.
// Type: Function
function rpass()
{
$min=6; // minimum length of password
$max=15; // maximum length of password
$pwd="";   //to store generated password
// Use a for loop to generate a random number then use that
// number to call it's coresponding letter in ascii.
for($i=0;$i<rand($min,$max);$i++){
    $num=rand(48,122);
    if(($num > 97 && $num < 122)){   
        $pwd.=chr($num);
    }else if(($num > 65 && $num < 90)){ 
            $pwd.=chr($num);
    }else if(($num >48 && $num < 57)){
            $pwd.=chr($num);
    }else if($num==95){ 
        $pwd.=chr($num);
    }else{
        $i--;
    }
}
// Return the newly generated password to whatever called it.
// You can now email it, display or whatever you need to back
// in your main function that called this one.
return $pwd;
}
// Use: rpass(); 


Last edited by Elmseeker : 13-Jan-2003 at 11:12.
  #2  
Old 13-Jan-2003, 10:43
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
How cool is this!?

I was just sitting down to do the 'forgot password' feature of GIDTopsites&trade; Member Control Panel and bam! I get a random password generating function dropping on my lap! :grin:

Of course I voted YES!
  #3  
Old 10-Mar-2003, 14:29
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
Is there anyway of extending this generator to create phonetic/pronouncalbe passwords for when people register to a site. You may think it sounds strange but it can help people come back to the site (maybe not webmasters as they seem to know what they are doing.
  #4  
Old 11-Mar-2003, 12:08
Elmseeker's Avatar
Elmseeker Elmseeker is offline
Awaiting Email Confirmation
 
Join Date: Jan 2003
Posts: 87
Elmseeker is on a distinguished road
I wouldn't extend the current function for that purpose, it would be easier to write a whole new function that randomly chooses 2 or 3 words from an array of words and puts them together to form the password...;)
  #5  
Old 01-Mar-2006, 09:23
TreyAU21's Avatar
TreyAU21 TreyAU21 is offline
Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 114
TreyAU21 has a spectacular aura aboutTreyAU21 has a spectacular aura about

Re: [function] Random Password Generator


All you would need would be a huge array of adjectives... and a huge array of nouns. Then pick a random adjective with a random noun... and Viola. You would end up getting temp passwords of "bluerainbow" and "windycheetah"... it's like the old Madlibs! :)
__________________
If practice makes perfect and nobody's perfect... why practice?

Homepage: http://www.treywhite.com
Blog: http://www.treywhite.com/blog.php
Web Design Company: http://www.ewebproductions.com
  #6  
Old 07-Apr-2006, 00:28
Tailzehhhh Tailzehhhh is offline
New Member
 
Join Date: Apr 2006
Posts: 7
Tailzehhhh is an unknown quantity at this point

Re: [function] Random Password Generator


Ooh, useful, thank you.
Last edited by admin : 07-Apr-2006 at 00:33. Reason: Please set up signature in your profile only
 

Recent GIDBlogNon-US citizens serving in the military by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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 Off
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a script for selecting random tabels and from those tabels selecting random ques mlt MySQL / PHP Forum 2 12-Sep-2003 09:01
Hide password skyloon MySQL / PHP Forum 2 08-Jul-2003 08:51
Random web page generator jrobbio Web Design Forum 1 27-May-2003 04:50
Random no longer JUST random... JdS GIDTopsites™ 0 12-Jan-2003 08:57

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:11.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.