Для удобочитаемых паролей я недавно использовал скрипт PHP, очень похожий на приведенный ниже. Это сработало хорошо. Конечно, пароли не будут невероятно безопасными (так как они подвержены атакам по словарю), но для запоминаемых или, по крайней мере, читаемых паролей это работает хорошо. Однако эту функцию не следует использовать как есть, она скорее для иллюстрации, чем что-либо еще.
function generatePassword($syllables = 2, $use_prefix = true)
{
// Define function unless it is already exists
if (!function_exists('arr'))
{
// This function returns random array element
function arr(&$arr)
{
return $arr[rand(0, sizeof($arr)-1)];
}
}
// Random prefixes
$prefix = array('aero', 'anti', 'auto', 'bi', 'bio',
'cine', 'deca', 'demo', 'dyna', 'eco',
'ergo', 'geo', 'gyno', 'hypo', 'kilo',
'mega', 'tera', 'mini', 'nano', 'duo',
'an', 'arch', 'auto', 'be', 'co',
'counter', 'de', 'dis', 'ex', 'fore',
'in', 'infra', 'inter', 'mal',
'mis', 'neo', 'non', 'out', 'pan',
'post', 'pre', 'pseudo', 'semi',
'super', 'trans', 'twi', 'vice');
// Random suffixes
$suffix = array('dom', 'ity', 'ment', 'sion', 'ness',
'ence', 'er', 'ist', 'tion', 'or',
'ance', 'ive', 'en', 'ic', 'al',
'able', 'y', 'ous', 'ful', 'less',
'ise', 'ize', 'ate', 'ify', 'fy', 'ly');
// Vowel sounds
$vowels = array('a', 'o', 'e', 'i', 'y', 'u', 'ou', 'oo', 'ae', 'ea', 'ie');
// 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?arr($prefix):'';
$password_suffix = arr($suffix);
for($i=0; $i<$syllables; $i++)
{
// selecting random consonant
$doubles = array('n', 'm', 't', 's');
$c = 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 .= arr($vowels);
if ($i == $syllables - 1) // if suffix begin with vovel
if (in_array($password_suffix[0], $vowels)) // add one more consonant
$password .= arr($consonants);
}
// selecting random suffix
$password .= $password_suffix;
return $password;
}