/
chkreg.c
50 lines (39 loc) · 1.38 KB
/
chkreg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*************************************************************************
CHKREG.C - Validates a key created by REGIT.C
Donated to the Public Domain by Craig Morrison 12 May 1994, use,
abuse, fold, spindle or mutilate anyway you see fit.
*************************************************************************/
#include "regkey.h"
/*************************************************************************
CHKREG accepts two arguments on its command line; The key value in
hexadecimal generated by REGIT and a string. You should end up with
XOR_PRIME after the XOR manipulations, if not, then the given key
was invalid.
*************************************************************************/
int main(int argc, char *argv[])
{
long keyval;
long key;
char *p;
char buf[128];
if (argc>2)
{
strcpy(buf, argv[1]);
strupr(buf);
sscanf(buf, "%8lX", &keyval);
keyval ^= XOR_POST_CRYPT;
strcpy(buf, argv[2]);
p = strrev(buf);
while(*p)
{
if (*p=='_')
*p = ' ';
key = (long) toupper(*p);
key ^= (long)XOR_CRYPT;
keyval ^= key;
p++;
}
printf("Key value = %08lX hex.\n", keyval);
}
return 0;
}