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