1 package day01;
2 import java.io.BufferedReader;
3 import java.io.IOException;
4 import java.io.InputStreamReader;
5
6 public class MyEclipseGen {
7 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.";
8
9 public String getSerial(String userId, String licenseNum) {
10 java.util.Calendar cal = java.util.Calendar.getInstance();
11 cal.add(1, 3);
12 cal.add(6, -1);
13 java.text.NumberFormat nf = new java.text.DecimalFormat("000");
14 licenseNum = nf.format(Integer.valueOf(licenseNum));
15 String verTime = new StringBuilder("-").append(
16 new java.text.SimpleDateFormat("yyMMdd").format(cal.getTime()))
17 .append("0").toString();
18 String type = "YE3MP-";
19 String need = new StringBuilder(userId.substring(0, 1)).append(type)
20 .append("300").append(licenseNum).append(verTime).toString();
21 String dx = new StringBuilder(need).append(LL).append(userId)
22 .toString();
23 int suf = this.decode(dx);
24 String code = new StringBuilder(need).append(String.valueOf(suf))
25 .toString();
26 return this.change(code);
27 }
28
29 private int decode(String s) {
30 int i;
31 char[] ac;
32 int j;
33 int k;
34 i = 0;
35 ac = s.toCharArray();
36 j = 0;
37 k = ac.length;
38 while (j < k) {
39 i = (31 * i) + ac[j];
40 j++;
41 }
42 return Math.abs(i);
43 }
44
45 private String change(String s) {
46 byte[] abyte0;
47 char[] ac;
48 int i;
49 int k;
50 int j;
51 abyte0 = s.getBytes();
52 ac = new char[s.length()];
53 i = 0;
54 k = abyte0.length;
55 while (i < k) {
56 j = abyte0;
57 if ((j >= 48) && (j <= 57)) {
58 j = (((j - 48) + 5) % 10) + 48;
59 } else if ((j >= 65) && (j <= 90)) {
60 j = (((j - 65) + 13) % 26) + 65;
61 } else if ((j >= 97) && (j <= 122)) {
62 j = (((j - 97) + 13) % 26) + 97;
63 }
64 ac = (char) j;
65 i++;
66 }
67 return String.valueOf(ac);
68 }
69
70 public MyEclipseGen() {
71 super();
72 }
73
74 public static void main(String[] args) {
75 try {
76 System.out.println("please input register name:");
77 BufferedReader reader = new BufferedReader(new InputStreamReader(
78 System.in));
79 String userId = null;
80 userId = reader.readLine();
81 MyEclipseGen myeclipsegen = new MyEclipseGen();
82 String res = myeclipsegen.getSerial(userId, "5");
83 System.out.println("Serial:" + res);
84 reader.readLine();
85 } catch (IOException ex) {
86 }
87 }
88
89 }