写穷举密码的算法
解决方案 »
- 同事没来上班,联系不上怎么办?
- 像这样的结构体可以直接赋值?
- 求TWinControl继承下的TShape!
- debug process is already running?
- 关于speedbutton
- TcoolWindowMain 是不是控件,谁有借用一下
- 如何在quickreport中实现这样的报表?
- delphi中调用chm文件
- 请问文件上传函数怎么用啊?
- 寻wjiachun
- 特急:locate('SNo,dfg',vararrayof([spinedit1.text,edit1.text]),[loPartialKey])提示没有定义vararrayof标识符,怎么办?
- 关于用CompactDatabase压缩带密码的数据库遇到的问题?
{
#define passwordmax 8//将生成密码的最大长度
char a[]="0123456789abcdefghijklmnopqrstuvwxyz";//可能的字符
long ndictcount=sizeof(a);//获得密码词典长度
char cpass[passwordmax+2];//将生成的密码
long nminl=1,nmaxl=3;//本例中密码长度从1-3
long array[passwordmax];//密码词典下标
assert(nminl<=nmaxl && nmaxl<=passwordmax);//容错保证
long nlength=nminl;
register long j,i=0;
bool bnext;
cstdiofile file;
file.open("c:\\dict.txt",cfile::modecreate|cfile::modewrite);
while(nlength<=nmaxl)
{
for(i=0;i<passwordmax;i++)
array[i]=0;
bnext=true;
while(bnext)
{
for(i=0;i<nlength;i++)
cpass[i]=a[array[i]];
cpass[i]='\0';
file.writestring(cpass);
file.writestring("\n");
for(j=nlength-1;j>=0;j--)//密码指针进位
{
array[j]++;
if(array[j]!=ndictcount-1)break;
else
{
array[j]=0;
if(j==0)bnext=false;
}
}
}
nlength++;
}
file.close();
}