程序生成MyEclipse10的注册码
1 package com.gaeainfo; 2 3 import java.io.BufferedReader; 4 import java.io.IOException; 5 import java.io.InputStreamReader; 6 7 public class MyEclipseGen { 8 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."; 9 10 11 public String getSerial(String userId, String licenseNum) { 12 java.util.Calendar cal = java.util.Calendar.getInstance(); 13 cal.add(1, 3); 14 cal.add(6, -1); 15 java.text.NumberFormat nf = new java.text.DecimalFormat("000"); 16 licenseNum = nf.format(Integer.valueOf(licenseNum)); 17 String verTime = new StringBuilder("-").append( 18 new java.text.SimpleDateFormat("yyMMdd").format(cal.getTime())) 19 .append("0").toString(); 20 String type = "YE3MP-"; 21 String need = new StringBuilder(userId.substring(0, 1)).append(type) 22 .append("300").append(licenseNum).append(verTime).toString(); 23 String dx = new StringBuilder(need).append(LL).append(userId) 24 .toString(); 25 int suf = this.decode(dx); 26 String code = new StringBuilder(need).append(String.valueOf(suf)) 27 .toString(); 28 return this.change(code); 29 } 30 31 32 private int decode(String s) { 33 int i; 34 char[] ac; 35 int j; 36 int k; 37 i = 0; 38 ac = s.toCharArray(); 39 j = 0; 40 k = ac.length; 41 while (j < k) { 42 i = (31 * i) + ac[j]; 43 j++; 44 } 45 return Math.abs(i); 46 } 47 private String change(String s) { 48 byte[] abyte0; 49 char[] ac; 50 int i; 51 int k; 52 int j; 53 abyte0 = s.getBytes(); 54 ac = new char[s.length()]; 55 i = 0; 56 k = abyte0.length; 57 while (i < k) { 58 j = abyte0[i]; 59 if ((j >= 48) && (j <= 57)) { 60 j = (((j - 48) + 5) % 10) + 48; 61 } else if ((j >= 65) && (j <= 90)) { 62 j = (((j - 65) + 13) % 26) + 65; 63 } else if ((j >= 97) && (j <= 122)) { 64 j = (((j - 97) + 13) % 26) + 97; 65 } 66 ac[i] = (char) j; 67 i++; 68 } 69 return String.valueOf(ac); 70 } 71 public MyEclipseGen() { 72 super(); 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 90 }
此笔记用来自我学习和分享知识,有不对的地方还请大家互相指教