Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advanced Random Password Generator
#1
Credits and Source: http://www.dreamincode.net/

Description:
Create random passwords with a chosen length and a specified number of numbers. Uses both lower case and capital letters, which are chosen at random. And example is: wep5Q268LtTe

Snippet:
PHP Code:
function passwordGen($length,$nums){
        
$lowLet "abcdefghijklmnopqrstuvwxyz";
        
$highLet "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        
$numbers "123456789";
        
$pass "";
        
$i 1;
        While (
$i <= $length){
            
$type rand(0,1);
            if (
$type == 0){
                if ((
$length-$i+1) > $nums){
                    
$type2 rand(0,1);
                    if (
$type2 == 0){
                        
$ran rand(0,25);
                        
$pass .= $lowLet[$ran];
                    }else{
                        
$ran rand(0,25);
                        
$pass .= $highLet[$ran];
                    }
                }else{
                    
$ran rand(0,8);
                    
$pass .= $numbers[$ran];
                    
$nums--;
                }
            }else{
                if (
$nums 0){
                    
$ran rand(0,8);
                    
$pass .= $numbers[$ran];
                    
$nums--;
                }else{
                    
$type2 rand(0,1);
                    if (
$type2 == 0){
                        
$ran rand(0,25);
                        
$pass .= $lowLet[$ran];
                    }else{
                        
$ran rand(0,25);
                        
$pass .= $highLet[$ran];
                    }
                }
            }
            
$i++;
        }
        return 
$pass;


Instructions: Just add to the appropriate page and call the procedure like passwordGen(12,4) for a password 12 letters long with 4 numbers like in the example: wep5Q268LtTe

Yeye That's It
Reply


Messages In This Thread
Advanced Random Password Generator - by zone - 11-06-2009, 05:40 AM
RE: Advanced Random Password Generator - by zone - 11-06-2009, 09:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Dynamic Text Generator TalishHF 5 1,954 01-16-2012, 02:24 PM
Last Post: Gaijin
  How hard would it be to make an signature generator? Extornia 3 1,288 01-11-2012, 08:24 PM
Last Post: Gaijin
  [SF Coders] Password Generator ★Cooldude★ 8 2,732 12-07-2011, 12:42 PM
Last Post: ★Cooldude★
  Random Image PHP Matt G 13 3,314 11-24-2010, 01:21 PM
Last Post: Sam
  Random Signature script Gaijin 8 4,773 01-24-2010, 05:08 PM
Last Post: Gaijin

Forum Jump:


Users browsing this thread: 1 Guest(s)