1
import java.io.BufferedReader;
2
import java.io.IOException;
3
import java.io.InputStreamReader;
4
import java.io.PrintStream;
5
import java.text.DecimalFormat;
6
import java.text.NumberFormat;
7
import java.text.SimpleDateFormat;
8
import java.util.Calendar;
9
10
public class MyEclipseRegister{
11
12
private static final String L = "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.";
13
14
public static void main(String[] args){
15
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
16
String userId = null;
17
int intLicenseNum = 1;
18
String strLicenseNum = null;
19
boolean bProFlag = true;
20
String strProFlag = null;
21
22
while ((userId == null) || ("".equals(userId.trim()))) {
23
System.out.print("用戶名: ");
24
try {
25
userId = br.readLine();
26
}
27
catch (IOException ioe1){
28
}
29
}
30
System.out.print("注冊碼可用的用戶數量(默認 1, 最大 999): ");
31
try {
32
strLicenseNum = br.readLine();
33
}
34
catch (IOException ioe2)
35
{
36
}
37
38
Object nf = new DecimalFormat("000");
39
if ((strLicenseNum == null) || ("".equals(strLicenseNum.trim())))
40
strLicenseNum = ((NumberFormat)nf).format(intLicenseNum);
41
else {
42
strLicenseNum = ((NumberFormat)nf).format(Integer.parseInt(strLicenseNum));
43
}
44
45
System.out.print("個人版 或 標準版(默認 個人版, n 標準版): ");
46
try {
47
strProFlag = br.readLine();
48
}
49
catch (IOException ioe3) {
50
}
51
if ((strProFlag != null) && (!("".equals(strProFlag.trim())))) {
52
bProFlag = false;
53
}
54
55
Calendar cal = Calendar.getInstance();
56
cal.add(1, 2);
57
cal.add(6, -1);
58
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
59
60
String need = userId.substring(0, 1) + "Y" +
61
((bProFlag) ? "E3MP" : "E2MY") + "-100" + strLicenseNum + "-" +
62
sdf.format(cal.getTime()) + "0";
63
String dx = need + "Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself." + userId;
64
int suf = decode(dx);
65
String code = need + suf;
66
System.out.println("注冊碼: " + change(code));
67
}
68
69
static int decode(String s) {
70
int i = 0;
71
char[] ac = s.toCharArray();
72
int j = 0;
73
for (int k = ac.length; j < k; ++j)
74
i = 31 * i + ac[j];
75
76
return Math.abs(i);
77
}
78
79
static String change(String s) {
80
if ((s == null) || (s.length() == 0))
81
return s;
82
byte[] abyte0 = s.getBytes();
83
char[] ac = new char[s.length()];
84
int i = 0;
85
for (int k = abyte0.length; i < k; ++i) {
86
int j = abyte0[i];
87
if ((j >= 48) && (j <= 57))
88
j = (j - 48 + 5) % 10 + 48;
89
else if ((j >= 65) && (j <= 90))
90
j = (j - 65 + 13) % 26 + 65;
91
else if ((j >= 97) && (j <= 122))
92
j = (j - 97 + 13) % 26 + 97;
93
ac[i] = (char)j;
94
}
95
return String.valueOf(ac);
96
}
97
}
98

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
