oxygenxml.oxygen_18.1 生成KEY代码_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > oxygenxml.oxygen_18.1 生成KEY代码

oxygenxml.oxygen_18.1 生成KEY代码

 2017/8/28 13:08:53  solong2008  程序员俱乐部  我要评论(0)
  • 摘要:oxygenxmlEclipse插件的Key生成器代码,做个保留,如果真有需要请付费购买正版importjava.io.BufferedReader;importjava.io.IOException;importjava.io.InputStreamReader;importjava.io.PrintStream;importjava.security.KeyFactory;importjava.security.NoSuchAlgorithmException;importjava
  • 标签:KEY 代码 XML
oxygenxml Eclipse插件的Key生成器代码,做个保留,如果真有需要请付费购买正版
class="java" name="code">
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
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;

public class Keygen {
	private static SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy", Locale.US);

	private static final byte[] privateKeyData = { 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 String registrationName;
	private String company;

	private static PrivateKey getPrivateKey() throws InvalidKeySpecException, NoSuchAlgorithmException {
		PKCS8EncodedKeySpec pKCS8EncodedKeySpec = new PKCS8EncodedKeySpec(privateKeyData);
		return KeyFactory.getInstance("DSA").generatePrivate(pKCS8EncodedKeySpec);
	}

	private static String convertString(String _string) {
		StringBuffer stringBuffer = new StringBuffer(_string);
		int length = stringBuffer.length();
		for (int i = 0; i < length; ++i) {
			if ("BADCEFGHIJKLNMOPQRSTUVWXZY0123456789 _-.@".indexOf(Character.toUpperCase(stringBuffer.charAt(i))) != -1)
				continue;
			stringBuffer.setCharAt(i, '_');
		}
		return stringBuffer.toString();
	}

	private static String inputString(BufferedReader _bufferedReader, String _message) throws IOException {
		String inputLine = null;
		do {
			System.out.print(_message);
			System.out.flush();
			inputLine = _bufferedReader.readLine();
		} while ((inputLine == null) || (inputLine.trim().length() == 0));
		return inputLine;
	}

	public Keygen(String _registrationName, String _company) {
		this.registrationName = null;
		this.company = null;
		this.registrationName = _registrationName;
		this.company = _company;
	}

	private String getLicenseString() throws Exception {
		StringBuffer buffer = new StringBuffer();
		buffer.append(convertString(this.registrationName));
		buffer.append(convertString(this.company));
		buffer.append(formatter.format(new Date()));
		buffer.append("0");
		buffer.append("1000");
		buffer.append(convertString("Enterprise"));
		buffer.append(convertString("[Author, Author-Component, XML-Editor, XSLT-Debugger, SVN-Client, Saxon-SA, Diff-Srv, Diff-App, 1]"));
		buffer.append(convertString("18"));
		return buffer.toString();
	}

	private String getLicenseSignature() throws Exception {
		Signature dsaSignature = Signature.getInstance("SHA1withDSA");
		dsaSignature.initSign(getPrivateKey());
		dsaSignature.update(getLicenseString().getBytes());

		return Base64.encodeBase64String(dsaSignature.sign());
	}

	private String getLicense() throws Exception {
		StringBuffer buffer = new StringBuffer();
		buffer.append("Registration_Name=" + this.registrationName).append('\n');
		buffer.append("Company=" + this.company).append('\n');
		buffer.append("Date=").append(formatter.format(new Date())).append('\n');
		buffer.append("Duration=-").append('\n');
		buffer.append("Number_of_Licenses=1000").append('\n');
		buffer.append("Category=Enterprise").append('\n');
		buffer.append("Component=Author,Author-Component,XML-Editor,XSLT-Debugger,SVN-Client,Saxon-SA,Diff-Srv,Diff-App,1").append('\n');
		buffer.append("Version=18").append('\n');
		buffer.append("SGN=" + getLicenseSignature());
		return buffer.toString();
	}

	public static void main(String[] _args) {
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
		try {
			System.out.println("==================================================");
			System.out.println("=== <oXygen/>XML Editor v17.x license generator ===");
			System.out.println("==================================================");
			System.out.println();
			String registrationName = inputString(bufferedReader, "Registration name : ");
			String company = inputString(bufferedReader, "Company           : ");
			System.out.println();
			System.out.println("==================================================");
			System.out.println("License: ");
			System.out.println("==================================================");
			System.out.println();
			System.out.println(new Keygen(registrationName, company).getLicense());
			System.out.println();
			System.out.println("==================================================");
		} catch (Exception _exception) {
			_exception.printStackTrace();
		} finally {
			try {
				bufferedReader.close();
			} catch (IOException localIOException1) {
			}
		}
	}
}
发表评论
用户名: 匿名