IDEA注册算法

IntelliJ IDEA 加密算法一直没变过

128位RSA加密

 

import java.math.BigInteger;
import java.util.Random;
import java.util.zip.CRC32;


    static String CalcSerial(String userName) {
        byte[] paramArrayOfByte = {0x1, 0x0b,
                0x00, 0x00, 0x00, 0x00,
                0x0, 0x0,
                0x71, 0x45,
                0x00, 0x00};
        long l = System.currentTimeMillis() >> 16;
        paramArrayOfByte[2] = (byte) (l & 0xff);
        paramArrayOfByte[3] = (byte) (l >> 8 & 0xff);
        paramArrayOfByte[4] = (byte) (l >> 16 & 0xff);
        paramArrayOfByte[5] = (byte) (l >> 24 & 0xff);

        CRC32 localCRC32 = new CRC32();
        Random rdm = new Random(System.currentTimeMillis());
        int paramInt = rdm.nextInt();
        paramInt = (paramInt > 0) ? paramInt % 100000 : (0 - paramInt) % 100000;

        if (userName != null) {
            for (int i = 0; i < userName.length(); i++) {
                localCRC32.update(userName.charAt(i));
            }
        }

        localCRC32.update(paramInt);
        localCRC32.update(paramInt >> 8);
        localCRC32.update(paramInt >> 16);
        localCRC32.update(paramInt >> 24);

        for (int i = 0; i < paramArrayOfByte.length - 2; i++) {
            localCRC32.update(paramArrayOfByte[i]);
        }
        long crc = localCRC32.getValue();
        paramArrayOfByte[10] = (byte) crc;
        paramArrayOfByte[11] = (byte) (crc >> 8);

        BigInteger localBigInteger2 = new BigInteger(paramArrayOfByte);
        final BigInteger Modulus = new BigInteger("86f71688cdd2612ca117d1f54bdae029", 16);  //Modulus (N)
        final BigInteger privateExponent = new BigInteger("430D187DE8BB3F18FB0A986E6B7163BD", 16);  //Private Exponent (D)
        BigInteger localBigInteger1 = localBigInteger2.modPow(privateExponent, Modulus);
        String serial = encodeGroups(localBigInteger1);
        return String.format("%1$05d-", paramInt) + serial;
    }

    public static String encodeGroups(BigInteger paramBigInteger) {
        BigInteger localBigInteger = BigInteger.valueOf(60466176L);
        StringBuffer localStringBuffer = new StringBuffer();
        int i = 0;
        while (paramBigInteger.compareTo(BigInteger.ZERO) != 0) {
            int j = paramBigInteger.mod(localBigInteger).intValue();
            String str2 = encodeGroup(j);
            if (i > 0) {
                localStringBuffer.append("-");
            }
            localStringBuffer.append(str2);
            paramBigInteger = paramBigInteger.divide(localBigInteger);
            i++;
        }
        String str1 = localStringBuffer.toString();
        return str1;
    }

    public static String encodeGroup(int paramInt) {
        StringBuffer localStringBuffer = new StringBuffer();
        for (int j = 0; j < 5; j++) {
            int k = paramInt % 36;
            char c;
            if (k < 10) {
                c = (char) (48 + k);
            } else {
                c = (char) (65 + k - 10);
            }
            localStringBuffer.append(c);
            paramInt /= 36;
        }
        return localStringBuffer.toString();
    }

 

点赞