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
#2
Just like my own, except in PHP. Looks good.
I have been studying the traits and dispositions of the "lower animals" (so called) and contrasting them with the traits and dispositions of man. I find the result humiliating to me.
--Mark Twain
Reply
#3
(11-06-2009, 02:26 PM)Korchidoom Wrote: Just like my own, except in PHP. Looks good.

Good to read that it is useful for you. Thanks for your comments, be happy always Smile
Reply


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

Forum Jump:


Users browsing this thread: 2 Guest(s)