- 论坛徽章:
- 0
|
循环的问题
原帖由 "hughr" 发表:
用以上代码产生乱数
如果嵌入一个循环中
以使每一次循环产生的乱数不相同?
请帮忙
谢谢
不是随便乱数就好。如果要密码不容易猜到,又要好记住,一般会生成一个元音辅音搭配的单词来,叫什么可以读出来的(Pronounceable )的密码,好在有前辈已经写好了这样的东西了,我们抄来就可以了。
- // +----------------------------------------------------------------------+
- // | PHP Pronounceable Password Generator |
- // +----------------------------------------------------------------------+
- // | Author: Max Dobbie-Holman <max@blueroo.net>; |
- // +----------------------------------------------------------------------+
- //
- // View the demo at http://www.blueroo.net/max/pwdgen.php
- /**
- * Generates an 8 character pronounceable password.
- *
- * @author Max Dobbie-Holman <max@blueroo.net>;
- * @version 1.0
- */
- function mkPasswd() {
- $consts='bcdgklmnprst';
- $vowels='aeiou';
- for ($x=0; $x < 6; $x++) {
- mt_srand ((double) microtime() * 1000000);
- $const[$x] = substr($consts,mt_rand(0,strlen($consts)-1),1);
- $vow[$x] = substr($vowels,mt_rand(0,strlen($vowels)-1),1);
- }
- return $const[0] . $vow[0] .$const[2] . $const[1] . $vow[1] . $const[3] . $vow[3] . $const[4];
- }
复制代码 |
|