-
-
[原创]第一题代码+注册机
-
发表于:
2007-8-23 18:32
6366
-
BOOL GenRegCode(HWND hWnd)
{
int len,i;
TCHAR szName[MAXINPUTLEN]={0};
TCHAR szSerial[MAXINPUTLEN]={0};
//TCHAR szBuffer[MAXINPUTLEN]={0};
long key=0x13572468, eax=0;
unsigned char checksum[10]={0};
unsigned char magic[1024]="1213121412131215121312141213121612131214121312151213121412131217121312141213121512131214121312161213121412131215121312141213121812131214121312151213121412131216121312141213121512131214121312171213121412131215121312141213121612131214121312151213121412131219";
unsigned char tmpstring[1024]={0};
len=GetDlgItemText(hWnd, IDC_NAME, szName, sizeof(szName)/sizeof(TCHAR)+1); // 取姓名
for(i=0; i<len; i++)
{
eax = ((DWORD)szName[i]+key)*0x3721273+0x24681357;
key = (eax<<25)|(eax>>7);
}
for(i=1; i<9; i++)
{
checksum[i] = (key>>i)&1;
}
checksum[9] = 1;
do
{
eax = findindex(checksum, 1, 10);
if(eax==-1)break;
if(checksum[eax+1]==1)
{
wsprintf(tmpstring, "%d", eax+1);
strcat(szSerial, tmpstring);
checksum[eax+1]=0;
}
else
{
checksum[eax]=0;
while(eax--)
{
memset(tmpstring, 0, sizeof(tmpstring));
strncpy(tmpstring, magic, 1<<(eax));
strcat(szSerial, tmpstring);
}
}
}while(1);
len=strlen(szSerial);
for(i=0; i<len; i++)
{
szSerial[i]=0x30+(10+(szSerial[i]-0x30)-((DWORD)key>>(i%0x1f))%10)%10;
}
SetDlgItemText(hWnd, IDC_OUT, szSerial); // 显示正确的序列号
return TRUE;
}
int findindex(char * input, char ch, int len)
{
int i;
for(i=0; i<len; i++)
if(input[i]==ch)return i;
return -1;
}
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)