intellij idea14 注册码

http://blog.csdn.net/u010567606/article/details/40858347
分类: Java
[java]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1. package test;  
  2.   
  3. import java.math.BigInteger;  
  4. import java.util.Date;  
  5. import java.util.Random;  
  6. import java.util.zip.CRC32;  
  7.   
  8. public class keygen {  
  9.        
  10.     private static final int version=14;  
  11.    
  12.     /** 
  13.      * @param s 
  14.      * @param i 
  15.      * @param bytes 
  16.      * @return 
  17.      */  
  18.     public static short getCRC(String s, int i, byte bytes[]) {  
  19.         CRC32 crc32 = new CRC32();  
  20.         if (s != null) {  
  21.             for (int j = 0; j < s.length(); j++) {  
  22.                 char c = s.charAt(j);  
  23.                 crc32.update(c);  
  24.             }  
  25.         }  
  26.         crc32.update(i);  
  27.         crc32.update(i >> 8);  
  28.         crc32.update(i >> 16);  
  29.         crc32.update(i >> 24);  
  30.         for (int k = 0; k < bytes.length - 2; k++) {  
  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.         BigInteger beginner1 = BigInteger.valueOf(0x39aa400L);  
  43.         StringBuilder sb = new StringBuilder();  
  44.         for (int i = 0; biginteger.compareTo(BigInteger.ZERO) != 0; i++) {  
  45.             int j = biginteger.mod(beginner1).intValue();  
  46.             String s1 = encodeGroup(j);  
  47.             if (i > 0) {  
  48.                 sb.append("-");  
  49.             }  
  50.             sb.append(s1);  
  51.             biginteger = biginteger.divide(beginner1);  
  52.         }  
  53.         return sb.toString();  
  54.     }  
  55.    
  56.     /** 
  57.      * @param i 
  58.      * @return 
  59.      */  
  60.     public static String encodeGroup(int i) {  
  61.         StringBuilder sb = new StringBuilder();  
  62.         for (int j = 0; j < 5; j++) {  
  63.             int k = i % 36;  
  64.             char c;  
  65.             if (k < 10) {  
  66.                 c = (char) (48 + k);  
  67.             } else {  
  68.                 c = (char) ((65 + k) - 10);  
  69.             }  
  70.             sb.append(c);  
  71.             i /= 36;  
  72.         }  
  73.         return sb.toString();  
  74.     }  
  75.    
  76.     /** 
  77.      * @param name 
  78.      * @param days 
  79.      * @param id 
  80.      * @return 
  81.      */  
  82.     public static String MakeKey(String name, int days, int id) {  
  83.         id %= 100000;  
  84.         byte bkey[] = new byte[12];  
  85.         bkey[0] = (byte1// Product type: IntelliJ IDEA is 1  
  86.         bkey[1] = version;  
  87.         Date d = new Date();  
  88.         long ld = (d.getTime() >> 16);  
  89.         bkey[2] = (byte) (ld & 255);  
  90.         bkey[3] = (byte) ((ld >> 8) & 255);  
  91.         bkey[4] = (byte) ((ld >> 16) & 255);  
  92.         bkey[5] = (byte) ((ld >> 24) & 255);  
  93.         days &= 0xffff;  
  94.         bkey[6] = (byte) (days & 255);  
  95.         bkey[7] = (byte) ((days >> 8) & 255);  
  96.         bkey[8] = 105;  
  97.         bkey[9] = -59;  
  98.         bkey[10] = 0;  
  99.         bkey[11] = 0;  
  100.         int w = getCRC(name, id % 100000, bkey);  
  101.         bkey[10] = (byte) (w & 255);  
  102.         bkey[11] = (byte) ((w >> 8) & 255);  
  103.         BigInteger pow = new BigInteger("89126272330128007543578052027888001981"10);  
  104.         BigInteger mod = new BigInteger("86f71688cdd2612ca117d1f54bdae029"16);  
  105.         BigInteger k0 = new BigInteger(bkey);  
  106.         BigInteger k1 = k0.modPow(pow, mod);  
  107.         String s0 = Integer.toString(id);  
  108.         String sz = "0";  
  109.         while (s0.length() != 5) {  
  110.             s0 = sz.concat(s0);  
  111.         }  
  112.         s0 = s0.concat("-");  
  113.         String s1 = encodeGroups(k1);  
  114.         s0 = s0.concat(s1);  
  115.         return s0;  
  116.     }  
  117.    
  118.     public static void main(String[] args) {  
  119.         Random r = new Random();  
  120.         System.out.println("user name:" + "Ola" + " KEY:" + MakeKey("Ola"0, r.nextInt(Integer.MAX_VALUE)));  
  121.     }  
  122. }  

    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值