1 package TestCase; 2 import java.io.BufferedReader; 3 import java.io.IOException; 4 import java.io.InputStreamReader; 5 6 public class jihuo { 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 public String getSerial(String userId, String licenseNum) { 9 java.util.Calendar cal = java.util.Calendar.getInstance(); 10 cal.add(1, 3); 11 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 private int decode(String s) { 29 int i; 30 char[] ac; 31 int j; 32 int k; 33 i = 0; 34 ac = s.toCharArray(); 35 j = 0; 36 k = ac.length; 37 while (j < k) { 38 i = (31 * i) + ac[j]; 39 j++; 40 } 41 return Math.abs(i); 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 public jihuo() { 68 super(); 69 } 70 public static void main(String[] args) { 71 try { 72 System.out.println("please input register name:"); 73 BufferedReader reader = new BufferedReader(new InputStreamReader( 74 System.in)); 75 String userId = null; 76 userId = reader.readLine(); 77 jihuo myeclipsegen = new jihuo(); 78 String res = myeclipsegen.getSerial(userId, "5"); 79 System.out.println("Serial:" + res); 80 reader.readLine(); 81 } catch (IOException ex) { 82 } 83 } 84 }