function get_random_word($min_length, $max_length) $word = ''; $dictionary = '/usr/dict/words';
$fp = @fopen($dictionary, 'r');
if(!$fp)
return false;
$size = filesize($dictionary);
srand ((double) microtime() * 1000000);
$rand_location = rand(0, $size);
fseek($fp, $rand_location);
while (strlen($word)< $min_length || strlen($word)>$max_length || strstr($word, "'"))
{
if (feof($fp))
fseek($fp, 0); // if at end, go to start
$word = fgets($fp, 80); // skip first word as it could be partial
$word = fgets($fp, 80); // the potential password
};
$word=trim($word); // trim the trailing \n from fgets
return $word;
}问题1:像这样假如我传一个参数get_random_word(6,13)这样获取的随机单词作为密码使用可靠吗?是否跟使用的单词库有关?
问题2:使用的不是UNIX 这样的单词库我要从哪里找?
问题3:现在建站用户注册遗忘密码这个模块开发还会用这种方式来重置密码吗?
感谢各位解答~~
额,是圣经里面第一个项目使用的方法。如果是我的话就用一串ASCII码然后转成字符再连接N个就好了。
就是想问问圣经里面这方法有可取性么