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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
| #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
unsigned int digit(unsigned int v, unsigned int i)
{
v = v%(int)pow(10, i);
return v/(int)pow(10, i-1);
}
/*big random number*/
long lrand()
{
if (RAND_MAX == 0x7FFF)
return (long)((rand() << 16)| rand());
else
return rand();
}
int main()
{
const unsigned int mask[32] = {
0X3039, 0X1E240, 0X5464E, 0X6F855, 0X8AA52, 0XA5BF5, 0X980D0,
0XBADD0, 0X980D0, 0X30448, 0X30379, 0X8AF93, 0X30379, 0X7B9,
0XF2F90, 0X9FF66, 0X8AA52, 0XF3A0, 0X30379, 0X8AA52, 0X62AF,
0X2AD, 0X71FDC, 0X5A124, 0XFFB2, 0XB96D8, 0X2B18E, 0X4CDE4,
0X71FDC, 0X1068C, 0X765C3A63, 0X745C3533
};
const int i_dat[10] = {0x96, 0x95, 0x10, 0x23, 7, 0x15, 8, 3, 16, 17};
srand((unsigned int)time(NULL));
while (1) {
unsigned int d = 0;
unsigned int mid_number = 0;
char resp[128];
int i = 0;
while(1) {
d = lrand()%1000000;
if (d < 100000 || d%111111 == 0)
continue;
for (i = 0; i < 32; ++i) {
if (mask[i] == d)
break;
}
if (i==32)
break;
}
mid_number = d;
for (i=0; i<6; ++i) {
d = (i_dat[i]^(digit(mid_number, 6-i)+48)) + 4*d;
}
d = d%100000;
if (d < 10000)
continue;
printf("Serial number: SI3US-%d-%d\n", mid_number, d);
// try again
printf("Do you want to have a try, again(y|n)? ");
memset(resp, 0, 128);
scanf("%s", resp);
fflush(stdin);
if (resp[0]=='y' || resp[0]=='Y') {
continue;
} else {
printf("Good Bye!\n");
break;
}
}
return 0;
}
|