1. 用回调
void gen_words(char *buf,int buflen,int level)
{
char ** pptr;
int len;
if (buflen >= MAXPASS || level == 0){
printf("%s\n",buf);
return;
} /* output a word */
pptr = syllables ;
for (; *pptr != NULL ; pptr ++)
{
len = strlen(*pptr);
if ((buflen + len) <= MAXPASS)
{
strcpy(buf + buflen,*pptr);
gen_words(buf,buflen+len,level-1);
}
}
}
回调不理想的地方在于如果回调层次比较深(生成16位以上密码),而且生成密码之后马上用于运算的话,比较麻烦。生成算法和验证算法就杂糅在一起了...
2. GetBrouteforcePwd 写成N进制(N为密码字符集字符个数)转换函数 然后将字符一个个拼接起来
3. 还是N进制数字转换 不过GetNextPwd(char *NumStr); 传入一个字符串,返回下一个字符串
void InitMap()
{
memset(index_map, INVALID_NO, 256);
nCount = strlen(chars_set);
for (int i = 0; i < nCount; i++)
{
in