问题:1 . 代码用于加密不超过5位数的密码 . 当只留下1,2,3,4为语言时,我可以测试1,2,3,4位数 . 但它与5位数密码不兼容 . 2.我也希望使用代码一次测试不超过5位数的密码,但我不知道如何实现这一点?
else
{
string hash = argv[1];
string alphabet = "abcdefghijklmnopqrestuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
// salt is the first two letter of hash
// same key and same salt will come to the same hash
char salt[2];
salt[0] = hash[0];
salt[1] = hash[1];
char key[5];
int i,m,n,p,s;
for (i=0; i<strlen(alphabet); i++)
{
for (m=0; m<strlen(alphabet); m++)
{
for (n=0; n<strlen(alphabet);n++)
{
for (p=0; p<strlen(alphabet); p++)
{
for( s=0; s<strlen(alphabet);s++)
{
key[0]=alphabet[i];
key[1]=alphabet[m];
key[2]=alphabet[n];
key[3]=alphabet[p];
key[4]=alphabet[s];
if (strcmp(crypt(key,salt),hash) == 0)
{
printf("%s\n",key);
return 0;
}
}
}
}
}
}
}
printf("\n");
}