完整的代码如下,求前辈的解出序列号,然后求秒!!不胜感激~~
谁能解决谁就能人也!~呵呵,菜鸟勿扰
import java.security.MessageDigest;
public class PJMD5 {
public static boolean isRegister() throws Exception{
String s = "13N7IF1N11ZHZHZHZHZ"; //预设序列号,错误的………^_^ 求合法序列号
if ((s == null) || (s.length() != 19)) {
return false;
}
String v = s.substring(15);
s = s.substring(5, 9) + s.substring(10, 14) + s.substring(0, 4);
int j = 0;
for (int i = 0; i < 12; i++) {
j += s.charAt(i);
j = j * (i + 2) * 2 + i;
if (j % 2 == 0)
j++;
else
j += 2;
}
return v.equals(getMD5(s + Integer.toString(j)).substring(0, 4));
}
public static String optString(String s) {
if (s == null)
return "";
else
return s;
}
public static String getMD5(String text) throws Exception {
return getMD5(optString(text).getBytes("utf-8"));
}
public static String getMD5(byte[] bytes) throws Exception {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(bytes);
byte[] tmp = md.digest();
char[] str = new char[32];
int k = 0;
for (int i = 0; i < 16; i++) {
byte bt = tmp[i];
str[(k++)] = "C2E8D9A3B5F14607".charAt(bt >>> 4 & 0xF);
str[(k++)] = "C2E8D9A3B5F14607".charAt(bt & 0xF);
}
return new String(str);
}
public static void main(String[] args) throws Exception {
System.out.println(isRegister());
}
}