欢迎来到 嗅灵易学

零基础也能上手的脚本技术课,一对一答疑带你入门

答复

答复

哈哈,偶的长的很难看,大家将就看把

代码:

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;
}

注意:上传附件及图片大小不得大于30M。

⚠️ 版权声明:
本博客所有内容(含教程、源码、工具)仅供个人技术学习与研究交流使用,严禁商用、倒卖、二次分发及非法用途
未经作者书面授权,任何组织或个人不得转载、复制或用于其他平台,违者将追究相关责任。

0 0 0 举报
复制成功