// 长度计算
unsigned long ulong_user_len = 0, ulong_pass_len = 8;
unsigned long ulong_total_len = 0;
ulong_user_len = strlen(pchar_user_name);
if (ulong_user_len >= 8 || ulong_user_len < 2)
{
printf("User name lenth must between 2-7 byte!\n");
return 0;
}
ulong_total_len = ulong_user_len + ulong_pass_len;
ulong_total_len = ulong_total_len * ulong_total_len;
unsigned long ulong_name_add = 0;
unsigned long ulong_pass_add = 0;
unsigned long ulong_total_result = 0;
unsigned long ulong_tmp_pass = 10000000;
unsigned char auchar_password[9] = {0};
// 用户名和密码计算
for (i=0; i<ulong_user_len; i++)
{
ulong_name_add += pchar_user_name[i];
}
for (j=0; j<0xFFFFFF; j++)
{
itoa(ulong_tmp_pass, (char *)auchar_password, 10);
for (i=0; i<8; i++)
{
ulong_pass_add += auchar_password[i];
}
ulong_name_add = ulong_name_add & 0x0F;
ulong_pass_add = ulong_pass_add & 0x0F;
ulong_total_result = ulong_name_add * ulong_pass_add * 4;
if ((ulong_total_len - ulong_total_result) == 0x6d)
{
printf("The password is %s\n", auchar_password);
break;
}
ulong_tmp_pass++;
} |