1 package keygen; 2 3 import java. math. bigInteger; 4 import java. util. date; 5 import java.util.zip. CRC32; 6 7 public class Keygen {8 9 private static final int version = 14; 10 11/** 12 * @ param s 13 * @ param I 14 * @ param bytes 15 * @ return 16 */17 public static short getCRC (String s, int I, byte bytes []) {18 CRC32 crc32 = new CRC32 (); 19 if (s! = Null) {20 for (int j = 0; j <s. length (); j ++) {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 byte byte0 = bytes [k]; 31 crc32.update (byte0); 32} 33 return (short) (int) crc32.getValue (); 34} 35 36/** 37 * @ param biginteger 38 * @ return S Tring 39 */40 public static String encodeGroups (BigInteger biginteger) {41 BigInteger beginner1 = BigInteger. valueOf (0x39aa400L); 42 StringBuilder sb = new StringBuilder (); 43 for (int I = 0; biginteger. compareTo (BigInteger. ZERO )! = 0; I ++) {44 int j = biginteger. mod (beginner1 ). intValue (); 45 String s1 = encodeGroup (j); 46 if (I> 0) {47 sb. append ("-"); 48} 49 sb. append (s1); 50 biginteger = biginteger. divide (beginner1); 51} 52 return sb. toString (); 53} 54 55/** 56 * @ param I 57 * @ return 58 */59 public static String encodeGroup (int I) {60 StringBuilder sb = new StringBuilder (); 61 for (int j = 0; j <5; j ++) {62 int K = I % 36; 63 char c; 64 if (k <10) {65 c = (char) (48 + k); 66} else {67 c = (char) (65 + k)-10); 68} 69 sb. append (c); 70 I/= 36; 71} 72 return sb. toString (); 73} 74 75/** 76 * @ param name 77 * @ param days 78 * @ param id 79 * @ return 80 */81 public static String MakeKey (String name, int days, int id) {82 id % = 100000; 83 byte bkey [] = new byte [12]; 84 bkey [0] = (byte) 1; // Produc T type: IntelliJ IDEA is 1 85 bkey [1] = version; 86 Date d = new Date (); 87 long ld = (d. getTime ()> 16); 88 bkey [2] = (byte) (ld & 255); 89 bkey [3] = (byte) (ld> 8) & 255); 90 bkey [4] = (byte) (ld> 16) & 255); 91 bkey [5] = (byte) (ld> 24) & 255); 92 days & = 0 xffff; 93 bkey [6] = (byte) (days & 255); 94 bkey [7] = (byte) (days> 8) & 255); 95 bkey [8] = 105; 96 bkey [9] =-59; 97 bkey [10] = 0; 98 bkey [11] = 0; 99 int w = getCRC (name, id % 100000, bkey); 100 bkey [10] = (byte) (w & 255); 101 bkey [11] = (byte) (w> 8) & 255); 102 BigInteger pow = new BigInteger ("89126272330128007543578052027888001981", 10 ); 103 BigInteger mod = new BigInteger ("86f71688cdd2612ca117d1f54bdae029", 16); 104 BigInteger k0 = new BigInteger (bkey); 105 BigInteger k1 = k0.modPow (pow, mod ); 106 String s0 = Integer. t OString (id); 107 String sz = "0"; 108 while (s0.length ()! = 5) {109 s0 = sz. concat (s0); 110} 111 s0 = s0.concat ("-"); 112 String s1 = encodeGroups (k1); 113 s0 = s0.concat (s1); 114 return s0; 115} 116}
Random r = new Random (); String key = MakeKey (userName, 0, r. nextInt (Integer. MAX_VALUE ));
: Keygen-14.zip
IntelliJ IDEA 14 Keygen