標籤:style c class blog code java
1.建立MyEclipseGen.java檔案
2.添加如下代碼內容到MyEclipseGen.java檔案
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 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(new java.text.13 SimpleDateFormat("yyMMdd").format(cal.getTime())).append("0").14 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).toString();19 int suf = this.decode(dx);20 String code = new StringBuilder(need).append(String.valueOf(suf)).21 toString();22 return this.change(code);23 }24 private int decode(String s) {25 int i;26 char[] ac;27 int j;28 int k;29 i = 0;30 ac = s.toCharArray();31 j = 0;32 k = ac.length;33 while (j < k) {34 i = (31 * i) + ac[j];35 j++;36 }37 return Math.abs(i);38 }39 private String change(String s) {40 byte[] abyte0;41 char[] ac;42 int i;43 int k;44 int j;45 abyte0 = s.getBytes();46 ac = new char[s.length()];47 i = 0;48 k = abyte0.length;49 while (i < k) {50 j = abyte0[i];51 if ((j >= 48) && (j <= 57)) {52 j = (((j - 48) + 5) % 10) + 48;53 } else if ((j >= 65) && (j <= 90)) {54 j = (((j - 65) + 13) % 26) + 65;55 } else if ((j >= 97) && (j <= 122)) {56 j = (((j - 97) + 13) % 26) + 97;57 }58 ac[i] = (char) j;59 i++;60 }61 return String.valueOf(ac);62 }63 public MyEclipseGen() {64 super();65 }66 public static void main(String[] args) {67 try {68 System.out.println("please input register name:");69 BufferedReader reader = new BufferedReader(new InputStreamReader(70 System.in));71 String userId = null;72 userId = reader.readLine();73 MyEclipseGen myeclipsegen = new MyEclipseGen();74 String res = myeclipsegen.getSerial(userId, "20");75 System.out.println("Serial:" + res);76 reader.readLine();77 } catch (IOException ex) {78 }79 }80 }
3.編譯並運行MyEclipseGen.java檔案。
4.在運行時的命令視窗中按提示輸入“name”值,自動產生對應的註冊碼。
聲明:以上內容來自網路……