测试通过(请用在正途,呵呵)function createpassword() {
$passwordmax=8;
$a="0123456789abcdefghijklmnopqrstuvwxyz";//可能的字符
$ndictcount=strlen($a);
$cpass=array();$arrIndex=array();
$nminl=1;$nmaxl=3;//本例中密码长度从1-3
$nlength=$nminl;
assert($nminl<=$nmaxl && $nmaxl<=$passwordmax);
$fp=fopen("c:\\dict.txt","w");
while($nlength<=$nmaxl)
{
for($i=0;$i<$passwordmax;$i++)$arrIndex[$i]=0;
$bnext=true;
while($bnext){
for($i=0;$i<$nlength;$i++)$cpass[$i]=$a[$arrIndex[$i]];
fwrite($fp,implode($cpass,"")."\r\n");
for($j=$nlength-1;$j>=0;$j--){//密码指针进位
$arrIndex[$j]++;
if($arrIndex[$j]!=$ndictcount)
break;
else{
$arrIndex[$j]=0;
if($j==0)$bnext=false;
}
}
}
$nlength++;
}
fclose($fp);
echo "OK";
}
createpassword();
$passwordmax=8;
$a="0123456789abcdefghijklmnopqrstuvwxyz";//可能的字符
$ndictcount=strlen($a);
$cpass=array();$arrIndex=array();
$nminl=1;$nmaxl=3;//本例中密码长度从1-3
$nlength=$nminl;
assert($nminl<=$nmaxl && $nmaxl<=$passwordmax);
$fp=fopen("c:\\dict.txt","w");
while($nlength<=$nmaxl)
{
for($i=0;$i<$passwordmax;$i++)$arrIndex[$i]=0;
$bnext=true;
while($bnext){
for($i=0;$i<$nlength;$i++)$cpass[$i]=$a[$arrIndex[$i]];
fwrite($fp,implode($cpass,"")."\r\n");
for($j=$nlength-1;$j>=0;$j--){//密码指针进位
$arrIndex[$j]++;
if($arrIndex[$j]!=$ndictcount)
break;
else{
$arrIndex[$j]=0;
if($j==0)$bnext=false;
}
}
}
$nlength++;
}
fclose($fp);
echo "OK";
}
createpassword();
复杂的程序很好费服务器资源的。php类似于c,理论上可以做到你的程序。
要在php里面实现这个功能只能分批运行穷举。
比如:
a.php
这个是实现穷举的文件,然后要定义一个起点,比如$start.
每次程序读取这个标量然后这个变量规定的某个点继续穷举。
现在假设让程序每次穷举50000个密码,那么在穷举完5w个密码后就需要输出到页面一个js让程序可以继续运行下5w个密码:
<script>location.href='a.php?start=$startpoint'</script>
$startpoint=0,50000,100000,150000..........
直到穷举完毕为止...