51Testing软件测试网8lbE,}Mpackage test;51Testing软件测试网0tKK4V;JU
k1`
51Testing软件测试网 F}8L5in4b ftr"Eimportjava.io.*;51Testing软件测试网L1F9d-QQ"\1ET a+o,XX
51Testing软件测试网-C6N1~lG:O$mpublic class MyEclipseGen {51Testing软件测试网2t/Kj/xAFX
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.";51Testing软件测试网:x4[FV0e6]?Q
public String getSerial(String userId, String licenseNum) {51Testing软件测试网"g W k'E Sn9T8rt;c
java.util.Calendar cal = java.util.Calendar.getInstance();51Testing软件测试网7kD|g
g'c9g Y
cal.add(1, 3);51Testing软件测试网&aj @T6VD!]a
cal.add(6, -1);
1d?%]:x ?|+G7Mj:d(}0 java.text.NumberFormat nf = new java.text.DecimalFormat("000");51Testing软件测试网%?!i:B1y*Vi'Zk
licenseNum = nf.format(Integer.valueOf(licenseNum));51Testing软件测试网4|PPr
V'j,v;R
String verTime = new StringBuilder("-").append(new java.text.
y PRajRT#sJ,lm0 SimpleDateFormat("yyMMdd").format(cal.getTime())).append("0").
3`?;m};g[-d}F'l*i0 toString();
A/wCZ \9OX|e|0 String type = "YE3MP-";
%U$KU,d QI0 String need = new StringBuilder(userId.substring(0, 1)).append(type).51Testing软件测试网.fD{)Kd o!q
append("300").append(licenseNum).append(verTime).toString();
2X @6_7KQu}4p%}0 String dx = new StringBuilder(need).append(LL).append(userId).toString();51Testing软件测试网"|Xxh9FUG
int suf = this.decode(dx);51Testing软件测试网gd|D;j
String code = new StringBuilder(need).append(String.valueOf(suf)).51Testing软件测试网"j"~3y6~iI
toString();
Zvwc
ht0 return this.change(code);
fO@I6VE0 }
*t*u.H:b3y0S
GGW4ofu#[+v0 private int decode(String s) {
HR5h~-^0 int i;51Testing软件测试网tAZIgn
char[] ac;
s&{rG4oBugi0 int j;
K
B5vr VK0 int k;
2@X_j[ j{e0 i = 0;51Testing软件测试网 yv'v1Jem,[%Q.a
ac = s.toCharArray();
1eI7[5p3X0 j = 0;51Testing软件测试网$g^5jX}&N
k = ac.length;51Testing软件测试网,l&O]4A$@[
while (j < k) {
.~e%GL@B_0 i = (31 * i) + ac[j];
TNagEf7oOc0 j++;51Testing软件测试网Y?N _.}9gtX@%x)z
}51Testing软件测试网p!H.I([ j/H jc
return Math.abs(i);51Testing软件测试网r/m.QS_'B!l8qx&O
}51Testing软件测试网&wD1H~D'Q4O(L
51Testing软件测试网Gu
eFn}0q`%k private String change(String s) {51Testing软件测试网 ]S:k.KL,^gO7gQ
byte[] abyte0;
]W it,w,o8q0 char[] ac;51Testing软件测试网:E
lo;mr(H
int i;
b:h i,mX5g0 int k;51Testing软件测试网aji6qoV3E:U%H"S
int j;
#hudo@0 abyte0 = s.getBytes();
$w`p k{ d2D2jX0 ac = new char[s.length()];51Testing软件测试网 [dmd;?dg~ J
i = 0;
/Uud[2J Kg6r0 k = abyte0.length;51Testing软件测试网({E[(^ r4i+h8Zh)U
while (i < k) {
#VD;u#KN|0 j = abyte0[i];51Testing软件测试网#tx,HjYC4B/Z`5?
if ((j >= 48) && (j <= 57)) {
{`6N s)k9o.M@0 j = (((j - 48) + 5) % 10) + 48;51Testing软件测试网~V*C)_}2w#qL[
} else if ((j >= 65) && (j <= 90)) {51Testing软件测试网7|X-SyR
j = (((j - 65) + 13) % 26) + 65;
"F3hT j+a%c0 } else if ((j >= 97) && (j <= 122)) {
m)x/UgN qw7I0 j = (((j - 97) + 13) % 26) + 97;
6v(g0Fyw)l5Q0 }51Testing软件测试网8fN;y*WD,\S?^&w
ac[i] = (char) j;51Testing软件测试网OK!E/mk{
i++;
3\rX(dSm7T"n,l_"D0 }
ll
?9I#w K0 return String.valueOf(ac);51Testing软件测试网/zN1gr
~H R
q
}
Mf'qH
_gTe2E051Testing软件测试网?D zCD public MyEclipseGen() {51Testing软件测试网(|
`#p7D#~6['~Y6I(H
super();
vhbted.R&A`6p0 }51Testing软件测试网
M^,svk*BjY @
51Testing软件测试网%D4n)fe]3C1R0b| public static void main(String[] args) {51Testing软件测试网3quOdmE ^(uI
try {
;e'}*l`_9jQ
F0 System.out.println("please input register name:");51Testing软件测试网 {/cG-Qy)yM0L
BufferedReader reader = new BufferedReader(new InputStreamReader(51Testing软件测试网EM-l!i5y
System.in));
8n6c.kz4n&w0 String userId = null;51Testing软件测试网&x`~}MF;I(]"Z
userId = reader.readLine();
-U9P@}\0qL2aX0 MyEclipseGen myeclipsegen = new MyEclipseGen();51Testing软件测试网^%LS'MK^_Z
String res = myeclipsegen.getSerial(userId, "20");51Testing软件测试网9I;T9?zg[+L,c+k"Q(k
System.out.println("Serial:" + res);
ihJBZa0 reader.readLine();51Testing软件测试网*}M^/W4uq6O9Z!~_G f
} catch (IOException ex) {
e@)\9C]\$c0 }51Testing软件测试网([$Z"tB%^,}:Ta
V*x
}
hr,wb;x+t7]9K0}
8qwv`/W^2j'K9R0"rd&|UO;P.K0
yspq}T0o4t$E5g
mOO0===========================51Testing软件测试网 f\5|4X6e*N
O)Gj2}
B
hs R0运行该代码,在控制台中会出现:
AV d d6`;c N051Testing软件测试网q.brzWnQ!t3I#zplease input register name:
0KP9@O;x9y0×××××(你的name)51Testing软件测试网'|!k
nq.yA8m)A M1T
-@ p@'Dk _T1A
@0即生成序列号:51Testing软件测试网V"y/t8rA|{?'Oy
51Testing软件测试网,{1Ow7lI3tplease input register name:51Testing软件测试网_C2yP*Mnq
camille
7[7Gj}3JU!A0Serial:pLR8ZC-855575-53668556514322852
!p
aIu0xu:Ks1W0
d
I0\}-rG0