T4VN is an online PHP Help community that provides PHP Tutorials, PHP Examples, PHP Scripts, PHP Support
    HOME  |  HOSTING COUPON  |  TEMPLATE  |  PHP SCRIPTS  |  LINK TO US  |  LINK  |  REGISTER | CONTACT
::: Member Login :::
 Username
 Password
 
Forgot your password ?
::: PHP Tutotal :::
  PHP Basic (7)
  PHP Advanced (4)
  PHP Database (2)
  Coding Step By Step (8)
  PHP and AJAX (0)
::: PHP Example :::
  Arrays (1)
  Code Highlighters (3)
  Database Functions (12)
  Date & Time (5)
  E-Mail (6)
  Forms (5)
  Guestbooks (1)
  Logging (2)
  Miscellaneous (10)
  Password Generators (3)
  Randomizers (3)
  String Manipulation (10)
  User Authentication (6)
::: Search On T4VN :::
::: T4VN Statistics :::
  PHP Scripts : 61
  PHP Example : 67
  PHP Tutorials : 21
  PHP News : 93
  Total Coupon : 36
  Other Tutorials :
  Member : 209
  Visitor Online : 1
  Today Visit: 309
  Total Visitor : 262319
  Most Online : 31
::: Sponsored Links :::

PR 4 For This Webpage
Home Today :

Pattern based Password Generator

Author : rolfvandekrol

This password generator allows you to generate passwords from a password pattern.
The function is
string genPassword(string $pattern[, array $chardef]).
Every char in $pattern has a specific meaning which is defined in $chardef. By default the following chars are set:
v => lowercase vowels
c => lowercase consonants
V => uppercase vowels
C => uppercase consonants
w => uppercase & lowercase vowels,
d => uppercase & lowercase consonants,
a => lowercase alphabet,
A => uppercase alphabet,
b => uppercase & lowercase alphabet
# => special chars: !@#$%^&*(){}[]:;-=\\_+|<>?,./
0 => numbers
y => numbers & lowercase alphabet
Y => numbers & uppercase alphabet
x => numbers & uppercase & lowercase alphabet
z => all previously mentioned chars together

PHP Example :

<?
function genPassword($pattern,$chardef = array(
                                                    
'v' => 'aeiouy',
                                                    
'c' => 'bcdfghjklmnpqrstvwxz',
                                                    
'V' => 'AEIOUY',
                                                    
'C' => 'BCDFGHIJKLMNPQRSTVWXZ',
                                                    
'w' => 'aeiouyAEIOUY',
                                                    
'd' => 'bcdfghjklmnpqrstvwxzBCDFGHIJKLMNPQRSTVWXZ',
                                                    
'a' => 'abcdefghijklmnopqrstuvwxyz',
                                                    
'A' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                                                    
'b' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
                                                    
'#' => '!@#$%^&*(){}[]-=\_+|<>?,./',
                                                    
'0' => '1234567890',
                                                    
'y' => 'abcdefghijklmnopqrstuvwxyz1234567890',
                                                    
'Y' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
                                                    
'x' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
                                                    
'z' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*(){}[]-=\_+|<>?,./1234567890'
                                                   
))
{
    
$output "";
    
$chardef_keys array_keys($chardef);
    for(
$i=0;$i<strlen($pattern);$i++) {
        if(
in_array(substr($pattern,$i,1),$chardef_keys)) {
            
$output .= substr($chardef[substr($pattern,$i,1)],rand(0,strlen($chardef[substr($pattern,$i,1)])-1),1);
        }
    }
    return 
$output;
}
?>



Usage Example:

PHP Example :

<?
echo(genPassword("cv0cv0cv")); 
/* generates a pronouncable and relatively easy to remember but hardly crackable password */ 
echo(genPassword("zzzzzzzzzz")); 
/* generates a completely random, hard to crack password. */ 
/* use your creativity to make other patterns. */ 
echo(genPassword("xxxxxxxx",array('x'=>'abcdef0123456789'))); 
/* generates a password, just containing hexadecimal numbers */ 
?>


Other Example
Easy to remember password for the membership tutorials


::: Resources :::
  Links Directory
  Programming 2 3
  Webmaster 2 3
  Web Design 2 3
  Web Hosting 2 3
  Other Links 2 3
  Asian ShowBiz News
  Teach Seo For You
::: New Templates :::




::: Other Tutorials :::
 Program Design

  Powered By T4VN.NET - Version 2.0 - CopyRight © T4VN.NET 2005-2007