Public class keygen {/*** @ Param S * @ Param I * @ Param bytes * @ return */public static short getcrc (string S, int I, byte bytes []) {CRC32 CRC32 = new CRC32 (); If (s! = NULL) {for (Int J = 0; j <S. length (); j ++) {char c = S. charat (j); crc32.update (c) ;}} crc32.update (I); crc32.update (I> 8); crc32.update (I> 16 ); crc32.update (I> 24); For (int K = 0; k <bytes. length-2; k ++) {byte byte0 = bytes [k]; crc32.update (byte0);} return (short) (INT) crc32.getvalue ();} /*** @ Param biginteger * @ return string */public static string encodegroups (biginteger big Integer) {biginteger beginner1 = biginteger. valueof (0x39aa400l); stringbuilder sb = new stringbuilder (); For (INT I = 0; biginteger. compareto (biginteger. Zero )! = 0; I ++) {Int J = biginteger. moD (beginner1 ). intvalue (); string S1 = encodegroup (j); if (I> 0) {sb. append ("-");} sb. append (S1); biginteger = biginteger. divide (beginner1);} return sb. tostring ();}/*** @ Param I * @ return */public static string encodegroup (int I) {stringbuilder sb = new stringbuilder (); for (Int J = 0; j <5; j ++) {int K = I % 36; char C; If (k <10) {c = (char) (48 + k );} Else {c = (char) (65 + k)-10);} sb. append (c); I/= 36;} return sb. tostring ();}/*** @ Param name * @ Param days * @ Param ID * @ Param prtype * @ return */public static string makekey (string name, int days, int ID) {ID %= 100000; byte bkey [] = new byte [12]; bkey [0] = (byte) 1; // product type: intellij idea is 1 bkey [1] = 13; // version date d = new date (); long LD = (D. gettime ()> 16); bke Y [2] = (byte) (LD & 255); bkey [3] = (byte) (LD >> 8) & 255 ); bkey [4] = (byte) (LD> 16) & 255); bkey [5] = (byte) (LD> 24) & 255 ); days & = 0 xFFFF; bkey [6] = (byte) (days & 255); bkey [7] = (byte) (days> 8) & 255 ); bkey [8] = 105; bkey [9] =-59; bkey [10] = 0; bkey [11] = 0; int W = getcrc (name, Id % 100000, bkey); bkey [10] = (byte) (W & 255); bkey [11] = (byte) (W> 8) & 255); biginteger pow = New biginteger ("89126272330128007543578052027888001981", 10); biginteger mod = new biginteger ("Hangzhou", 16); biginteger K0 = new biginteger (bkey); biginteger k1 = k0.modpow (pow, moD); string S0 = integer. tostring (ID); string SZ = "0"; while (s0.length ()! = 5) {S0 = Sz. concat (S0);} S0 = s0.concat ("-"); string S1 = encodegroups (K1); S0 = s0.concat (S1); Return S0 ;} public static void main (string [] ARGs) {random r = new random (); system. out. println (makekey ("draem0507", 0, R. nextint (100000); // replace draem0507 with your name }}
Idea13 registration Machine