syncrosvn 的优点就不说了,全操作系统的svn,默认试用30天,提供keygen算法,仅供学习,请不用用于非法目的。否则后果自负
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Signature;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.apache.commons.codec.binary.Base64;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class Keygen {
private SimpleDateFormat sdf = new SimpleDateFormat(STRING_SET[21], Locale.US);
private static byte[] key = { 48, -126, 1, 76, 2, 1, 0, 48, -126, 1, 44, 6, 7,
42, -122, 72, -50, 56, 4, 1, 48, -126, 1, 31, 2, -127, -127, 0, -3, 127, 83, -127, 29,
117, 18, 41, 82, -33, 74, -100, 46, -20, -28, -25, -10, 17, -73, 82, 60, -17, 68, 0,
-61, 30, 63, -128, -74, 81, 38, 105, 69, 93, 64, 34, 81, -5, 89, 61, -115, 88, -6, -65,
-59, -11, -70, 48, -10, -53, -101, 85, 108, -41, -127, 59, -128, 29, 52, 111, -14, 102,
96, -73, 107, -103, 80, -91, -92, -97, -97, -24, 4, 123, 16, 34, -62, 79, -69, -87,
-41, -2, -73, -58, 27, -8, 59, 87, -25, -58, -88, -90, 21, 15, 4, -5, -125, -10, -45,
-59, 30, -61, 2, 53, 84, 19, 90, 22, -111, 50, -10, 117, -13, -82, 43, 97, -41, 42,
-17, -14, 34, 3, 25, -99, -47, 72, 1, -57, 2, 21, 0, -105, 96, 80, -113, 21, 35, 11,
-52, -78, -110, -71, -126, -94, -21, -124, 11, -16, 88, 28, -11, 2, -127, -127, 0, -9,
-31, -96, -123, -42, -101, 61, -34, -53, -68, -85, 92, 54, -72, 87, -71, 121, -108,
-81, -69, -6, 58, -22, -126, -7, 87, 76, 11, 61, 7, -126, 103, 81, 89, 87, -114, -70,
-44, 89, 79, -26, 113, 7, 16, -127, -128, -76, 73, 22, 113, 35, -24, 76, 40, 22, 19,
-73, -49, 9, 50, -116, -56, -90, -31, 60, 22, 122, -117, 84, 124, -115, 40, -32, -93,
-82, 30, 43, -77, -90, 117, -111, 110, -93, 127, 11, -6, 33, 53, 98, -15, -5, 98, 122,
1, 36, 59, -52, -92, -15, -66, -88, 81, -112, -119, -88, -125, -33, -31, 90, -27, -97,
6, -110, -117, 102, 94, -128, 123, 85, 37, 100, 1, 76, 59, -2, -49, 73, 42, 4, 23, 2,
21, 0, -106, -49, 66, -124, -79, -94, -48, -108, 26, -46, -57, -110, -117, 14, -38, 1,
-77, -127, 0, 14 };
private static byte[] key2 = { 48, -127, -15, 48, -127, -88, 6, 7, 42, -122, 72,
-50, 56, 4, 1, 48, -127, -100, 2, 65, 0, -4, -90, -126, -50, -114, 18, -54, -70, 38,
-17, -52, -9, 17, 14, 82, 109, -80, 120, -80, 94, -34, -53, -51, 30, -76, -94, 8, -13,
-82, 22, 23, -82, 1, -13, 91, -111, -92, 126, 109, -10, 52, 19, -59, -31, 46, -48,
-119, -101, -51, 19, 42, -51, 80, -39, -111, 81, -67, -60, 62, -25, 55, 89, 46, 23, 2,
21, 0, -106, 46, -35, -52, 54, -100, -70, -114, -69, 38, 14, -26, -74, -95, 38, -39,
52, 110, 56, -59, 2, 64, 103, -124, 113, -78, 122, -100, -12, 78, -23, 26, 73, -59, 20,
125, -79, -87, -86, -14, 68, -16, 90, 67, 77, 100, -122, -109, 29, 45, 20, 39, 27, -98,
53, 3, 11, 113, -3, 115, -38, 23, -112, 105, -77, 46, 41, 53, 99, 14, 28, 32, 98, 53,
77, 13, -94, 10, 108, 65, 110, 80, -66, 121, 76, -92, 3, 68, 0, 2, 65, 0, -18, -51, 60,
-47, 119, -65, 87, -108, -13, -86, 29, 120, -70, -38, 7, 27, -54, 55, -100, 79, -47,
35, 2, 106, -4, 39, -25, -51, -122, 49, -2, 73, -108, -107, -118, -106, 8, 43, -8,
-114, -76, 5, -122, 35, -20, -56, -51, 110, -62, 38, -74, 26, 11, -17, 47, -68, -17,
104, 120, -92, 28, 5, 47, 69 };
private String regName;
private String company;
private static final String[] STRING_SET = new String[22];
static {
STRING_SET[0] = "SHA1withDSA";
STRING_SET[1] = "Registration name : ";
STRING_SET[2] = "Company : ";
STRING_SET[3] = "License: ";
STRING_SET[4] = "================================================";
STRING_SET[5] = "==================================================";
STRING_SET[6] = "=== Syncro SVN Client v8.x license generator ===";
STRING_SET[7] = "[Author, Author-Component, XML-Editor, XSLT-Debugger, SVN-Client, Saxon-SA, Diff-Srv, Diff-App, 1]";
STRING_SET[8] = "Enterprise";
STRING_SET[9] = "9999";
STRING_SET[10] = "BADCEFGHIJKLNMOPQRSTUVWXZY0123456789 _-.@";
STRING_SET[11] = "DSA";
STRING_SET[12] = "Company=";
STRING_SET[13] = "Duration=-";
STRING_SET[14] = "Version=8";
STRING_SET[15] = "Date=";
STRING_SET[16] = "Registration_Name=";
STRING_SET[17] = "Category=Enterprise";
STRING_SET[18] = "Number_of_Licenses=" + STRING_SET[9];
STRING_SET[19] = "Component=Author,Author-Component,XML-Editor,XSLT-Debugger,SVN-Client,Saxon-SA,Diff-Srv,Diff-App,1";
STRING_SET[20] = "SGN=";
STRING_SET[21] = "MM-dd-yyyy";
}
private static PrivateKey getPrivateKey() throws InvalidKeySpecException,
NoSuchAlgorithmException {
PKCS8EncodedKeySpec spec = new PKCS8EncodedKeySpec(key);
return KeyFactory.getInstance(STRING_SET[11]).generatePrivate(spec); // pkcs8生成私钥
// X509EncodedKeySpec encodeKeySpec = new X509EncodedKeySpec(key2);
// KeyFactory keyFactory = KeyFactory.getInstance("DSA");
// PublicKey key = keyFactory.generatePublic(encodeKeySpec); // x509生成公钥
}
private static String replaceAll(String s) {
StringBuffer sb = new StringBuffer(s);
for (int i = 0; i < sb.length(); i++) {
if (STRING_SET[10].indexOf(Character.toUpperCase(sb.charAt(i))) == -1) {
sb.setCharAt(i, '_');
}
}
return sb.toString();
}
private static String inputContent(BufferedReader in, String value) throws IOException {
String str = null;
do {
System.out.print(value);
System.out.flush();
str = in.readLine();
if (str == null) {
break;
}
} while (str.trim().length() == 0);
return str;
}
public Keygen(String regName, String company) {
this.regName = regName;
this.company = company;
}
private String assemble() throws Exception {
StringBuffer sb = new StringBuffer();
sb.append(replaceAll(this.regName));
sb.append(replaceAll(this.company));
sb.append(sdf.format(new Date()));
sb.append("0");
sb.append(STRING_SET[9]);
sb.append(replaceAll(STRING_SET[8]));
sb.append(replaceAll(STRING_SET[7]));
sb.append(replaceAll("8"));
return sb.toString();
}
private String encode() throws Exception {
Signature sign = Signature.getInstance(STRING_SET[0]);
sign.initSign(getPrivateKey());
sign.update(assemble().getBytes());
return Base64.encodeBase64String(sign.sign());
}
private String genarate() throws Exception {
StringBuffer sb = new StringBuffer();
sb.append(STRING_SET[16] + this.regName).append('\n');
sb.append(STRING_SET[12] + this.company).append('\n');
sb.append(STRING_SET[15]).append(sdf.format(new Date())).append('\n');
sb.append(STRING_SET[13]).append('\n');
sb.append(STRING_SET[18]).append('\n');
sb.append(STRING_SET[17]).append('\n');
sb.append(STRING_SET[19]).append('\n');
sb.append(STRING_SET[14]).append('\n');
sb.append(STRING_SET[20] + encode());
return sb.toString();
}
public static void main(String[] args) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println(STRING_SET[4]);
System.out.println(STRING_SET[6]);
System.out.println(STRING_SET[4]);
System.out.println();
String regName = inputContent(in, STRING_SET[1]);
String company = inputContent(in, STRING_SET[2]);
System.out.println();
System.out.println(STRING_SET[5]);
System.out.println(STRING_SET[3]);
System.out.println(STRING_SET[5]);
System.out.println();
System.out.println(new Keygen(regName, company).genarate());
System.out.println();
System.out.println(STRING_SET[5]);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (IOException e) {
}
}
}
}