BBS水木清华站∶精华区
发信人: thinkin (强强), 信区: Linux
标 题: randomPass()
发信站: BBS 水木清华站 (Thu Feb 17 11:07:16 2000)
<?php
// returns a random string of alphanumerics
// $length is an integer specifying the length of
// the string to be returned
function randomPass($length = 6) {
// all the chars we want to use
$all = explode( " ",
"a b c d e f g h i j k l m n o p q r s t u v w x y z "
. "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
. "0 1 2 3 4 5 6 7 8 9");
for($i=0;$i<$length;$i++) {
srand((double)microtime()*1000000);
$randy = rand(0, 61);
$pass .= $all[$randy];
}
return $pass;
}
?>
--
人生到处知何似?
应似飞鸿踏雪泥。
泥上偶然留指爪,
鸿飞那复计东西!
※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.37.191]
BBS水木清华站∶精华区