1 import java.math.BigInteger;
2 import java.util.Date;
3 import java.util.Random;
4 import java.util.zip.CRC32;
5
6 public class keygen
7 {
8 /**
9 * @param s
10 * @param i
11 * @param bytes
12 * @return
13 */
14 public static short getCRC(String s, int i, byte bytes[])
15 {
16 CRC32 crc32 = new CRC32();
17 if (s != null)
18 {
19 for (int j = 0; j < s.length(); j++)
20 {
21 char c = s.charAt(j);
22 crc32.update(c);
23 }
24 }
25 crc32.update(i);
26 crc32.update(i >> 8);
27 crc32.update(i >> 16);
28 crc32.update(i >> 24);
29 for (int k = 0; k < bytes.length - 2; k++)
30 {
31 byte byte0 = bytes[k];
32 crc32.update(byte0);
33 }
34 return (short) (int) crc32.getValue();
35 }
36
37 /**
38 * @param biginteger
39 * @return String
40 */
41 public static String encodeGroups(BigInteger biginteger)
42 {
43 BigInteger beginner1 = BigInteger.valueOf(0x39aa400L);
44 StringBuilder sb = new StringBuilder();
45 for (int i = 0; biginteger.compareTo(BigInteger.ZERO) != 0; i++)
46 {
47 int j = biginteger.mod(beginner1).intValue();
48 String s1 = encodeGroup(j);
49 if (i > 0)
50 {
51 sb.append("-");
52 }
53 sb.append(s1);
54 biginteger = biginteger.divide(beginner1);
55 }
56 return sb.toString();
57 }
58
59 /**
60 * @param i
61 * @return
62 */
63 public static String encodeGroup(int i)
64 {
65 StringBuilder sb = new StringBuilder();
66 for (int j = 0; j < 5; j++)
67 {
68 int k = i % 36;
69 char c;
70 if (k < 10)
71 {
72 c = (char) (48 + k);
73 }
74 else
75 {
76 c = (char) ((65 + k) - 10);
77 }
78 sb.append(c);
79 i /= 36;
80 }
81 return sb.toString();
82 }
83
84 /**
85 * @param name
86 * @param days
87 * @param id
88 * @param prtype
89 * @return
90 */
91 public static String MakeKey(String name, int days, int id)
92 {
93 id %= 100000;
94 byte bkey[] = new byte[12];
95 bkey[0] = (byte) 1; // Product type: IntelliJ IDEA is 1
96 bkey[1] = 14; // version
97 Date d = new Date();
98 long ld = (d.getTime() >> 16);
99 bkey[2] = (byte) (ld & 255);
100 bkey[3] = (byte) ((ld >> 8) & 255);
101 bkey[4] = (byte) ((ld >> 16) & 255);
102 bkey[5] = (byte) ((ld >> 24) & 255);
103 days &= 0xffff;
104 bkey[6] = (byte) (days & 255);
105 bkey[7] = (byte) ((days >> 8) & 255);
106 bkey[8] = 105;
107 bkey[9] = -59;
108 bkey[10] = 0;
109 bkey[11] = 0;
110 int w = getCRC(name, id % 100000, bkey);
111 bkey[10] = (byte) (w & 255);
112 bkey[11] = (byte) ((w >> 8) & 255);
113 BigInteger pow = new BigInteger("89126272330128007543578052027888001981", 10);
114 BigInteger mod = new BigInteger("86f71688cdd2612ca117d1f54bdae029", 16);
115 BigInteger k0 = new BigInteger(bkey);
116 BigInteger k1 = k0.modPow(pow, mod);
117 String s0 = Integer.toString(id);
118 String sz = "0";
119 while (s0.length() != 5)
120 {
121 s0 = sz.concat(s0);
122 }
123 s0 = s0.concat("-");
124 String s1 = encodeGroups(k1);
125 s0 = s0.concat(s1);
126 return s0;
127 }
128
129 public static void main(String[] args)
130 {
131 if (args.length == 0)
132 {
133 System.err.printf("*** Usage: %s name%n", keygen.class.getCanonicalName());
134 System.exit(1);
135 }
136 Random r = new Random();
137 System.out.println(MakeKey(args[0], 0, r.nextInt(100000)));
138 }
139 }
C0FHYYCJ22-eyJsaWNlbnNlSWQiOiJDMEZIWVlDSjIyIiwibGljZW5zZWVOYW1lIjoid2VpIGh1YW5nIiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IiIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJmYWxsYmFja0RhdGUiOiIyMDE2LTAyLTI1IiwicGFpZFVwVG8iOiIyMDE2LTAyLTI1In1dLCJoYXNoIjoiMjE2MDg1MS8wIiwiZ3JhY2VQZXJpb2REYXlzIjo3LCJhdXRvUHJvbG9uZ2F0Z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