码迷,mamicode.com
首页 > 其他好文 > 详细

IntelliJ IDEA 14 Keygen

时间:2014-11-06 21:43:02      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   java   for   

  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 String
 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; // Product 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 &= 0xffff;
 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.toString(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

标签:style   blog   http   io   color   ar   os   java   for   

原文地址:http://www.cnblogs.com/zhangtingkuo/p/4079899.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!