1import java.io.BufferedReader;
2import java.io.IOException;
3import java.io.InputStreamReader;
4import java.io.PrintStream;
5import java.text.DecimalFormat;
6import java.text.NumberFormat;
7import java.text.SimpleDateFormat;
8import java.util.Calendar;
9
10public class MyEclipseRegister{
11
12private 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
14public 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
posted on 2011-04-26 10:28
方涛升 阅读(502)
评论(1) 编辑 收藏 所属分类:
j2ee