home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #define CODESIZE 30
-
- char lctab[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";
- char codekey[CODESIZE + 1] = "DHCJWKWA55DE N7XL4JEWLKM079AQ5";
- char refcode[CODESIZE + 1] = "XT5VIRXBSIAY2N4DPHCAJSZUHMPTQ7";
- char cypher[CODESIZE + 1] = "007441IBMCD210000ALE53967INT61";
- char liccode[CODESIZE + 1] = "DHCJWKssssssssssL4JlllKMdccc__";
-
-
- int chartonum(char c)
- {
- int i;
-
- for (i=0; lctab[i] != '\0'; i++)
- if (lctab[i] == c)
- return i;
-
- return -1;
- }
-
- char numtochar(int i)
- {
- return lctab[i];
- }
-
- int procnum(int val)
- {
- val = val % (int)(sizeof(lctab) - 1);
- if (val < 0)
- val += sizeof(lctab) - 1;
- return val;
- }
-
- void sumcodes(char* ca, char* cb, char* cr)
- {
- int i;
-
- for (i=0; i<CODESIZE; i++)
- cr[i] = numtochar(procnum(chartonum(ca[i]) + chartonum(cb[i])));
- }
-
- void subcodes(char* ca, char* cb, char* cr)
- {
- int i;
-
- for (i=0; i<CODESIZE; i++)
- cr[i] = numtochar(procnum(chartonum(ca[i]) - chartonum(cb[i])));
- }
-
- void printcode(char* code)
- {
- int i;
-
- for (i=0; i<CODESIZE; i++) {
- if (i % 5 == 0 && i)
- printf("-");
- printf("%c", code[i]);
- }
- }
-
- int stripcode(char* sc, char* dc)
- {
- int i1=0, i2=0, cc=0, i, dash=0;
- char c;
-
- _strupr(sc);
- while (sc[i1]) {
- c = sc[i1];
- if (c == '-') {
- for (i=cc; i<5; i++)
- dc[i2++] = ' ';
- cc = 0;
- dash++;
- } else if (cc > 4)
- return 0;
- else {
- dc[i2++] = c;
- cc++;
- }
- i1++;
- }
- for (i=cc; i<5; i++)
- dc[i2++] = ' ';
-
- return dash == 5;
- }
-
- void checksum(char* code)
- {
- int i, len, val=0;
- char buf[10];
-
- len = strlen(code) - 2;
- for (i=0; i < len; i++)
- val += code[i];
- _itoa(val, buf, 10);
- strncpy(code + len, buf + strlen(buf) - 2, 2);
- }
-
- int main()
- {
- char buf[100];
-
- printf("Active Media Eclipse 2.1 License Key Generator\n");
-
- printf("Enter the Activation Reference Code (exactly, with dashes and spaces)\n>");
- if (scanf("%35[^\n]", buf) != 1) {
- printf("Unexpected error\n");
- return 1;
- }
- if (!stripcode(buf, refcode)) {
- printf("Invalid reference code\n");
- return 1;
- }
- //printf("refcode : %s\n", refcode);
- sumcodes(codekey, refcode, cypher);
- //printf("cypher : %s\n", cypher);
- strncpy(liccode + 6, cypher, 5);
- strncpy(liccode + 11, cypher + 20, 5);
- strncpy(liccode + 19, cypher + 9, 3);
- strncpy(liccode + 25, cypher + 6, 3);
- liccode[24] = cypher[5];
- checksum(liccode);
- //printf("liccode : %s\n", liccode);
- sumcodes(liccode, refcode, liccode);
- subcodes(liccode, cypher, liccode);
- printf("\nLicense Code : ");
- printcode(liccode);
- printf("\n");
- printf("\nEnter the above code including any spaces into your AME registration dialog\n");
-
- return 0;
- }