Intellij IDEA 14的注册机及源代码

来源:互联网 发布:crm数据分析师招聘 编辑:程序博客网 时间:2024/05/16 18:39
注册机下载
IntelliJ IDEA 14 注册机及源代码

软件界面

程序源代码

IDEAKeyGen.java

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package ideakeygen;import javafx.application.Application;import javafx.fxml.FXMLLoader;import javafx.scene.Parent;import javafx.scene.Scene;import javafx.scene.image.Image;import javafx.stage.Stage;/** * * @author splas */public class IDEAKeyGen extends Application {        @Override    public void start(Stage stage) throws Exception {        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));                Scene scene = new Scene(root);                // 设置窗体标题        stage.setTitle("IntelliJ IDEA 14 注册机");                 // 设置窗体图标        stage.getIcons().add(new Image(getClass().getResourceAsStream("FireEyes.png")));                stage.sizeToScene();        stage.centerOnScreen();        stage.setResizable(false);                stage.setScene(scene);        stage.show();    }    /**     * @param args the command line arguments     */    public static void main(String[] args) {        launch(args);    }    }


FXMLDocumentController.java

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */package ideakeygen;import java.math.BigInteger;import java.net.URL;import java.util.Date;import java.util.Random;import java.util.ResourceBundle;import java.util.zip.CRC32;import javafx.beans.value.ObservableValue;import javafx.event.ActionEvent;import javafx.fxml.FXML;import javafx.fxml.Initializable;import javafx.scene.control.Button;import javafx.scene.control.TextField;import javafx.scene.input.Clipboard;import javafx.scene.input.ClipboardContent;import javafx.stage.Stage;/** * * @author splas */public class FXMLDocumentController implements Initializable {        @FXML    private TextField textFieldUserId;        @FXML    private TextField textFieldKey;         @FXML    private void handleButtonCopy(ActionEvent event) {        Clipboard clipboard = Clipboard.getSystemClipboard();        ClipboardContent content = new ClipboardContent();        content.putString(textFieldKey.getText());        clipboard.setContent(content);    }        @FXML    private void handleButtonClose(ActionEvent event) {                ((Stage)((Button)(event.getSource())).getScene().getWindow()).close();    }        @Override    public void initialize(URL url, ResourceBundle rb) {        // TODO        textFieldKey.setEditable(false);        Random r = new Random();                textFieldUserId.textProperty().addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> {            if(newValue.isEmpty())            {                textFieldKey.clear();            }            else            {                textFieldKey.setText(MakeKey(newValue, 0, r.nextInt(100000)));            }                    });    }        /* ---------------------------------------            注册机算法      ---------------------------------------- */    /**     * @param s     * @param i     * @param bytes     * @return     */    public static short getCRC(String s, int i, byte bytes[])    {        CRC32 crc32 = new CRC32();        if (s != null)        {            for (int j = 0; j < s.length(); j++)            {                char c = s.charAt(j);                crc32.update(c);            }        }        crc32.update(i);        crc32.update(i >> 8);        crc32.update(i >> 16);        crc32.update(i >> 24);        for (int k = 0; k < bytes.length - 2; k++)        {            byte byte0 = bytes[k];            crc32.update(byte0);        }        return (short) (int) crc32.getValue();    }    /**     * @param biginteger     * @return String     */    public static String encodeGroups(BigInteger biginteger)    {        BigInteger beginner1 = BigInteger.valueOf(0x39aa400L);        StringBuilder sb = new StringBuilder();        for (int i = 0; biginteger.compareTo(BigInteger.ZERO) != 0; i++)        {            int j = biginteger.mod(beginner1).intValue();            String s1 = encodeGroup(j);            if (i > 0)            {                sb.append("-");            }            sb.append(s1);            biginteger = biginteger.divide(beginner1);        }        return sb.toString();    }    /**     * @param i     * @return     */    public static String encodeGroup(int i)    {        StringBuilder sb = new StringBuilder();        for (int j = 0; j < 5; j++)        {            int k = i % 36;            char c;            if (k < 10)            {                c = (char) (48 + k);            }            else            {                c = (char) ((65 + k) - 10);            }            sb.append(c);            i /= 36;        }        return sb.toString();    }    /**     * @param name     * @param days     * @param id     * @return     */    public static String MakeKey(String name, int days, int id)    {        id %= 100000;        byte bkey[] = new byte[12];        bkey[0] = (byte) 1; // Product type: IntelliJ IDEA is 1        bkey[1] = 14; // version        Date d = new Date();        long ld = (d.getTime() >> 16);        bkey[2] = (byte) (ld & 255);        bkey[3] = (byte) ((ld >> 8) & 255);        bkey[4] = (byte) ((ld >> 16) & 255);        bkey[5] = (byte) ((ld >> 24) & 255);        days &= 0xffff;        bkey[6] = (byte) (days & 255);        bkey[7] = (byte) ((days >> 8) & 255);        bkey[8] = 105;        bkey[9] = -59;        bkey[10] = 0;        bkey[11] = 0;        int w = getCRC(name, id % 100000, bkey);        bkey[10] = (byte) (w & 255);        bkey[11] = (byte) ((w >> 8) & 255);        BigInteger pow = new BigInteger("89126272330128007543578052027888001981", 10);        BigInteger mod = new BigInteger("86f71688cdd2612ca117d1f54bdae029", 16);        BigInteger k0 = new BigInteger(bkey);        BigInteger k1 = k0.modPow(pow, mod);        String s0 = Integer.toString(id);        String sz = "0";        while (s0.length() != 5)        {            s0 = sz.concat(s0);        }        s0 = s0.concat("-");        String s1 = encodeGroups(k1);        s0 = s0.concat(s1);        return s0;    }}

FXMLDocument.fxml

<?xml version="1.0" encoding="UTF-8"?><?import javafx.geometry.*?><?import java.lang.*?><?import java.util.*?><?import javafx.scene.*?><?import javafx.scene.control.*?><?import javafx.scene.layout.*?><AnchorPane id="AnchorPane" prefHeight="239.0" prefWidth="392.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ideakeygen.FXMLDocumentController">   <children>      <GridPane alignment="CENTER" layoutX="5.0" layoutY="10.0" prefHeight="218.0" prefWidth="380.0">         <columnConstraints>            <ColumnConstraints hgrow="ALWAYS" />            <ColumnConstraints />         </columnConstraints>         <rowConstraints>            <RowConstraints />            <RowConstraints />            <RowConstraints />         </rowConstraints>         <children>            <TextField fx:id="textFieldUserId" layoutX="73.0" layoutY="41.0">               <GridPane.margin>                  <Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />               </GridPane.margin>            </TextField>            <Button fx:id="buttonCopy" layoutX="261.0" layoutY="93.0" minHeight="40.0" minWidth="60.0" mnemonicParsing="false" onAction="#handleButtonCopy" text="拷贝" GridPane.columnIndex="1" GridPane.rowIndex="1">               <GridPane.margin>                  <Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />               </GridPane.margin>            </Button>            <Button fx:id="buttonClose" layoutX="107.0" layoutY="144.0" minHeight="40.0" minWidth="100.0" mnemonicParsing="false" onAction="#handleButtonClose" text="关闭" GridPane.columnSpan="2" GridPane.halignment="CENTER" GridPane.rowIndex="2">               <GridPane.margin>                  <Insets bottom="16.0" left="16.0" right="16.0" top="16.0" />               </GridPane.margin>            </Button>            <TextField fx:id="textFieldKey" layoutX="73.0" layoutY="93.0" GridPane.rowIndex="1">               <GridPane.margin>                  <Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />               </GridPane.margin>            </TextField>         </children>      </GridPane>   </children></AnchorPane>


参考文章

IntelliJ IDEA 14 注册码

1 0