MyEclipse 序列号生成代码
根据程序运行提示输入用户名即可生成注册码
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 import java.io.*; 2 3 public class MyEclipseGen { 4 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."; 5 6 public String getSerial(String userId, String licenseNum) { 7 java.util.Calendar cal = java.util.Calendar.getInstance(); 8 cal.add(1, 3); 9 cal.add(6, -1); 10 java.text.NumberFormat nf = new java.text.DecimalFormat("000"); 11 licenseNum = nf.format(Integer.valueOf(licenseNum)); 12 String verTime = new StringBuilder("-").append( 13 new java.text.SimpleDateFormat("yyMMdd").format(cal.getTime())) 14 .append("0").toString(); 15 String type = "YE3MP-"; 16 String need = new StringBuilder(userId.substring(0, 1)).append(type) 17 .append("300").append(licenseNum).append(verTime).toString(); 18 String dx = new StringBuilder(need).append(LL).append(userId) 19 .toString(); 20 int suf = this.decode(dx); 21 String code = new StringBuilder(need).append(String.valueOf(suf)) 22 .toString(); 23 return this.change(code); 24 } 25 26 private int decode(String s) { 27 int i; 28 char[] ac; 29 int j; 30 int k; 31 i = 0; 32 ac = s.toCharArray(); 33 j = 0; 34 k = ac.length; 35 while (j < k) { 36 i = (31 * i) + ac[j]; 37 j++; 38 } 39 return Math.abs(i); 40 } 41 42 private String change(String s) { 43 byte[] abyte0; 44 char[] ac; 45 int i; 46 int k; 47 int j; 48 abyte0 = s.getBytes(); 49 ac = new char[s.length()]; 50 i = 0; 51 k = abyte0.length; 52 while (i < k) { 53 j = abyte0[i]; 54 if ((j >= 48) && (j <= 57)) { 55 j = (((j - 48) + 5) % 10) + 48; 56 } else if ((j >= 65) && (j <= 90)) { 57 j = (((j - 65) + 13) % 26) + 65; 58 } else if ((j >= 97) && (j <= 122)) { 59 j = (((j - 97) + 13) % 26) + 97; 60 } 61 ac[i] = (char) j; 62 i++; 63 } 64 return String.valueOf(ac); 65 } 66 67 public MyEclipseGen() { 68 super(); 69 } 70 71 public static void main(String[] args) { 72 try { 73 System.out.println("please input register name:"); 74 BufferedReader reader = new BufferedReader(new InputStreamReader( 75 System.in)); 76 String userId = null; 77 userId = reader.readLine(); 78 MyEclipseGen myeclipsegen = new MyEclipseGen(); 79 String res = myeclipsegen.getSerial(userId, "20"); 80 System.out.println("Serial:" + res); 81 reader.readLine(); 82 } catch (IOException ex) { 83 } 84 } 85 }
posted on 2014-04-13 19:13 PolarisSherlock 阅读(151) 评论(0) 编辑 收藏 举报