1
package com.incors.plaf.alloy;
2
3
import java.io.*;
4
import java.util.GregorianCalendar;
5
import java.util.zip.CRC32;
6
import java.util.*;
7
8
public class ch
{
9
public ch()
{
10
}
11
12
private static void a()
{
13
if(a)
14
return;
15
bi.a("alloy.licenseCode",cr()); // feed serial automatically
16
String s=bi.a("alloy.licenseCode");
17
if(s == null)
18
try
{
19
InputStream inputstream=(com.incors.plaf.alloy.ch.class).getClassLoader().
20
getResourceAsStream("alloylnf.lic");
21
if(inputstream != null)
{
22
InputStreamReader inputstreamreader=new InputStreamReader(inputstream,
23
"ISO-8859-1");
24
BufferedReader bufferedreader=new BufferedReader(inputstreamreader);
25
s=bufferedreader.readLine();
26
System.out.println(s);
27
bi.a("alloy.licenseCode",s);
28
bufferedreader.close();
29
inputstream.close();
30
}
31
}
32
catch(Exception exception)
{}
33
if(s != null)
{
34
int l=s.indexOf('#');
35
int i1=s.indexOf('#',l + 1);
36
int j1=s.indexOf('#',i1 + 1);
37
f=s.substring(0,l);
38
if(f.length() > 1)
39
j=a(f);
40
e=s.substring(l + 1,i1);
41
d=s.substring(0,i1);
42
g=Long.parseLong(s.substring(i1 + 1,j1),36);
43
h=Long.parseLong(s.substring(j1 + 1),36);
44
b();
45
}
46
a=true;
47
}
48
49
private static void b()
{
50
i.update((h % 127L + d).getBytes());
51
if(i.getValue() != g)
{
52
b=false;
53
return;
54
}
55
if(j != null && (new GregorianCalendar()).after(j))
{ // 試用號過期
56
b=false;
57
return;
58
}
59
b=true;
60
if(j != null && (new GregorianCalendar()).after(new GregorianCalendar(2003,7,12)))
{ // 如果使用期大于1年
61
GregorianCalendar gregoriancalendar=new GregorianCalendar();
62
gregoriancalendar.add(1,1);
63
if(j.after(gregoriancalendar))
{
64
c=false;
65
return;
66
}
67
}
68
c=true;
69
}
70
71
private static GregorianCalendar a(String s)
{
72
int l=Integer.parseInt(s.substring(0,4));
73
int i1=Integer.parseInt(s.substring(5,7));
74
int j1=Integer.parseInt(s.substring(8,10));
75
return new GregorianCalendar(l,i1 - 1,j1 + 1);
76
}
77
78
public static boolean c()
{
79
if(!a)
80
a();
81
return bi.a("alloy.licenseCode") != null;
82
}
83
84
public static boolean d()
{
85
if(!a)
86
a();
87
return b;
88
}
89
90
public static boolean e()
{
91
if(!a)
92
a();
93
return c;
94
}
95
96
private static boolean a=false;
97
private static boolean b=false;
98
private static boolean c=false;
99
private static String d;
100
public static String e;
101
public static String f;
102
public static long g=0L;
103
public static long h=0L;
104
private static CRC32 i=new CRC32();
105
public static GregorianCalendar j;
106
107
private static String cr()
{ // 自動生成序列號,比當(dāng)前時間晚一個月
108
Calendar cal=new GregorianCalendar();
109
cal.add(cal.MONTH,1);
110
111
String s="";
112
int year=cal.get(cal.YEAR);
113
int month=cal.get(cal.MONTH);
114
int day=cal.get(cal.DAY_OF_MONTH);
115
116
s+=year + "/" + (month < 10 ? "0" + month : month) + "/" + (day < 10 ? "0" + day
117
: day);
118
s+="#oop@vip.163.com#128cw93#1a193l";
119
120
int l=s.indexOf('#');
121
int i1=s.indexOf('#',l + 1);
122
int j1=s.indexOf('#',i1 + 1);
123
124
String e=s.substring(l + 1,i1);
125
String d=s.substring(0,i1);
126
String sg=s.substring(i1 + 1,j1);
127
Long g=Long.parseLong(sg,36);
128
Long h=Long.parseLong(s.substring(j1 + 1),36);
129
130
CRC32 crc=new CRC32();
131
crc.update((h % 127L + d).getBytes());
132
Long ii=crc.getValue();
133
StringBuffer sn=new StringBuffer(s).replace(i1 + 1,j1,Long.toString(ii,36));
134
return sn.toString();
135
}
136
}
137

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

76

77

78



79

80

81

82

83

84



85

86

87

88

89

90



91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107



108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

關(guān)鍵代碼處有注釋,我就詳細(xì)講一下cr()。
由于Alloy的序列號的時間比當(dāng)前時間晚一年以上也視作invalid,因此我在cr()中動態(tài)生成一個序列號,該序列號比當(dāng)前時間晚一個月,使用bi.a()注入程序中(15行)。
111行到133行是具體的算號過程,可見“128cw93”和“1a1931”其實是兩個36進制的數(shù)。
第133行把算得的校驗值替換118行生成的字符串中的相應(yīng)位置上的字符串,生成新的序列號。