1 import java.io.BufferedReader;
2 import java.io.IOException;
3 import java.io.InputStreamReader;
4 /**
5 1、打开MyEclipse建立java Project,任意取个名字就行。
6 2、建立一个名字为MyEclipseGen的类文件,内容见下面附件。
7 3、运行该代码,在控制台中会出现:xx 根据提示输入即可生成注册序列号
8 * @author 刘凯
9 *
10 */
11 public class MyEclipseGen {
12 private static final String LL = "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 String getSerial(String userId, String licenseNum) {
15 java.util.Calendar cal = java.util.Calendar.getInstance();
16 cal.add(1, 3);
17 cal.add(6, -1);
18 java.text.NumberFormat nf = new java.text.DecimalFormat("000");
19 licenseNum = nf.format(Integer.valueOf(licenseNum));
20 String verTime = new StringBuilder("-").append(
21 new java.text.SimpleDateFormat("yyMMdd").format(cal.getTime()))
22 .append("0").toString();
23 String type = "YE3MP-";
24 String need = new StringBuilder(userId.substring(0, 1)).append(type)
25 .append("300").append(licenseNum).append(verTime).toString();
26 String dx = new StringBuilder(need).append(LL).append(userId)
27 .toString();
28 int suf = this.decode(dx);
29 String code = new StringBuilder(need).append(String.valueOf(suf))
30 .toString();
31 return this.change(code);
32 }
33
34 private int decode(String s) {
35 int i;
36 char[] ac;
37 int j;
38 int k;
39 i = 0;
40 ac = s.toCharArray();
41 j = 0;
42 k = ac.length;
43 while (j < k) {
44 i = (31 * i) + ac[j];
45 j++;
46 }
47 return Math.abs(i);
48 }
49
50 private String change(String s) {
51 byte[] abyte0;
52 char[] ac;
53 int i;
54 int k;
55 int j;
56 abyte0 = s.getBytes();
57 ac = new char[s.length()];
58 i = 0;
59 k = abyte0.length;
60 while (i < k) {
61 j = abyte0[i];
62 if ((j >= 48) && (j <= 57)) {
63 j = (((j - 48) + 5) % 10) + 48;
64 } else if ((j >= 65) && (j <= 90)) {
65 j = (((j - 65) + 13) % 26) + 65;
66 } else if ((j >= 97) && (j <= 122)) {
67 j = (((j - 97) + 13) % 26) + 97;
68 }
69 ac[i] = (char) j;
70 i++;
71 }
72 return String.valueOf(ac);
73 }
74
75 public MyEclipseGen() {
76 super();
77 }
78
79 public static void main(String[] args) {
80 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
81 String userId = null;
82 String strLicenseNum = null;
83 while (userId == null || "".equals(userId.trim())) {
84 System.out.print("userId: ");
85 try {
86 userId = br.readLine();
87 } catch (IOException ioexception) {
88 }
89 }
90 System.out.print("Number of licenses(default 1, max 999): ");
91 try {
92 strLicenseNum = br.readLine();
93 } catch (IOException ioexception1) {
94 }
95 MyEclipseGen obj = new MyEclipseGen();
96 System.out.println("Subscription Code: "
97 + obj.getSerial(userId, strLicenseNum));
98 }
99 }