.01
.02
.03
.04
.05
.06
.07
.08
.09
.10
.11
.12
.13
.14
.15
.16
.17
.18
.19
.20
.21
.22
.23
.24
.25
.26
.27
.28
.29
.30
.31
.32
.33
.34
.35
.36
.37
.38
.39
.40
.41
.42
.43
.44
.45
.46
.47
.48
.49
.50
.51
.52
.53
.54
.55
.56
.57
.58
.59
.60
.61
.62
.63
.64
.65
.66
.67
.68
.69
.70
.71
|
|
<?php
/******************************************************************************/
/* */
/* __ ____ */
/* ___ / / ___ / __/__ __ _____________ ___ */
/* / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-< */
/* / .__/_//_/ .__/___/\___/\_,_/_/ \__/\__/___/ */
/* /_/ /_/ */
/* */
/* */
/******************************************************************************/
/* */
/* Titre : Générer des mot de passe avec prefixe + suffixe et des... */
/* */
/* URL : http://www.phpsources.org/scripts196-PHP.htm */
/* Auteur : Avina */
/* Date édition : 03 Jan 2007 */
/* */
/******************************************************************************/
function ae_gen_password($syllables = 3, $use_prefix = false){
// Define function unless it is already exists
if (!function_exists('ae_arr')) {
// This function returns random array element
function ae_arr(&$arr) {
return $arr[rand(0, sizeof($arr)-1)];
}
}
// 20 prefixes
$prefix = array('aero', 'anti', 'auto', 'bi', 'bio',
'cine', 'deca', 'demo', 'dyna', 'eco',
'ergo', 'geo', 'gyno', 'hypo', 'kilo',
'mega', 'tera', 'mini', 'nano', 'duo');
// 10 random suffixes
$suffix = array('dom', 'ity', 'ment', 'sion', 'ness',
'ence', 'er', 'ist', 'tion', 'or');
// 8 vowel sounds
$vowels = array('a', 'o', 'e', 'i', 'y', 'u', 'ou', 'oo');
// 20 random consonants
$consonants = array('w', 'r', 't', 'p', 's', 'd', 'f', 'g', 'h', 'j',
'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'qu');
$password = $use_prefix?ae_arr($prefix):'';
$password_suffix = ae_arr($suffix);
for($i=0; $i<$syllables; $i++) {
// selecting random consonant
$doubles = array('n', 'm', 't', 's');
$c = ae_arr($consonants);
if (in_array($c, $doubles)&&($i!=0)) {
// maybe double it
if (rand(0, 2) == 1)
// 33% probability
$c .= $c;
}
$password .= $c;
//
// selecting random vowel
$password .= ae_arr($vowels);
if ($i == $syllables - 1)
// if suffix begin with vovel
if (in_array($password_suffix[0], $vowels))
// add one more consonant
$password .= ae_arr($consonants); }
// selecting random suffix
$password .= $password_suffix;
return $password;
}
?>
|