MyEclipse6.0生成注册码类
import java.io.bufferedreader;import java.io.ioexception;import java.io.inputstreamreader;public class test { public static string vertimestr; 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."; public string getserial(string userid, string licensenum) { java.util.calendar cal = java.util.calendar.getinstance(); cal.add(1, 3); cal.add(6, -1); java.text.numberformat nf = new java.text.decimalformat("000"); licensenum = nf.format(integer.valueof(licensenum)); string vertime = new stringbuilder("-").append(new java.text. simpledateformat("yymmdd").format(cal.gettime())).append("0"). tostring(); string type = "ye3mp-"; string need = new stringbuilder(userid.substring(0, 1)).append(type). append("300").append(licensenum).append(vertime).tostring(); string dx = new stringbuilder(need).append(ll).append(userid).tostring(); int suf = this.decode(dx); string code = new stringbuilder(need).append(string.valueof(suf)). tostring(); vertimestr="20"+(new java.text. simpledateformat("yymmdd").format(cal.gettime())).tostring(); return this.change(code); } private int decode(string s) { int i; char[] ac; int j; int k; i = 0; ac = s.tochararray(); j = 0; k = ac.length; while (j < k) { i = (31 * i) + ac[j]; j++; } return math.abs(i); } private string change(string s) { byte[] abyte0; char[] ac; int i; int k; int j; abyte0 = s.getbytes(); ac = new char[s.length()]; i = 0; k = abyte0.length; while (i < k) { j = abyte0[i]; if ((j >= 48) && (j <= 57)) { j = (((j - 48) + 5) % 10) + 48; } else if ((j >= 65) && (j <= 90)) { j = (((j - 65) + 13) % 26) + 65; } else if ((j >= 97) && (j <= 122)) { j = (((j - 97) + 13) % 26) + 97; } ac[i] = (char) j; i++; } return string.valueof(ac); } public test() { super(); } public static void main(string[] args) { try { system.out.println("please input register name:"); bufferedreader reader = new bufferedreader(new inputstreamreader( system.in)); string userid = null; userid = reader.readline(); test myeclipsegen = new test(); string res = myeclipsegen.getserial(userid, "20"); system.out.println("serial:" + res); system.out.println("有效期至:" + vertimestr); //reader.readline(); } catch (ioexception ex) { } }}?