home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
-
- unsigned int crc16(char* name)
- {
- unsigned int res;
-
- asm {
- xor ax,ax
- xor si,si
- }
- _loc1:
- asm {
- xor dx,dx
- mov cx,ax
- mov di,name
- add di,si
- mov dl,byte ptr ss:[di]
- xor cx,dx
- and cx,0x000F
- mov bx,cx
- shl bx,0x05
- add bx,cx
- shl bx,0x07
- add cx,bx
- shr ax,0x04
- xor cx,ax
- mov ax,cx
- shr dx,0x04
- and ax,0x000F
- and dx,0x000F
- xor ax,dx
- mov dx,ax
- shl dx,0x05
- add dx,ax
- shl dx,0x07
- add ax,dx
- shr cx,0x04
- xor ax,cx
- inc si
- cmp si,0x0020
- jl _loc1
- mov res,ax
- }
- return res;
- }
-
- void genserial(char* name, char* ser)
- {
- unsigned int crc;
- int i;
-
- for (i=strlen(name); i<0x20; i++)
- name[i] = ' ';
- name[0x20] = 0;
- crc = crc16(name);
- srand(crc);
- //printf("crc16=%x\n", crc);
- sprintf(ser, "%03d%06u%05d", rand() / 33, crc+3, rand());
- }
-
- void main()
- {
- char uname[100];
- char serial[30];
-
- printf("ChromaPIX Serial# generator (by fOSSiL)\n");
- printf("\nEnter User Name\n> ");
- gets(uname);
- genserial(uname, serial);
- printf("\nSerial Number : %s\n", serial);
- }