Idea keygen generates key code

Source: Internet
Author: User
Tags crc32

ImportJava.math.BigInteger;Importjava.util.Date;ImportJava.util.Random;Importjava.util.zip.CRC32; Public classkeygen {/**     * @paramS *@paramI *@parambytes *@return     */     Public Static  ShortGETCRC (String S,intIbytebytes[]) {CRC32 CRC32=NewCRC32 (); if(s! =NULL) {             for(intj = 0; J < S.length (); J + +) {                Charc =S.charat (j);            Crc32.update (c);        }} crc32.update (i); Crc32.update (i>> 8); Crc32.update (i>> 16); Crc32.update (i>> 24);  for(intk = 0; K < bytes.length-2; k++) {            byteBYTE0 =Bytes[k];        Crc32.update (BYTE0); }        return( Short) (int) Crc32.getvalue (); }    /**     * @paramBigInteger *@returnString*/     Public StaticString encodegroups (BigInteger BigInteger) {BigInteger beginner1= Biginteger.valueof (0x39aa400l); StringBuilder SB=NewStringBuilder ();  for(inti = 0; Biginteger.compareto (biginteger.zero)! = 0; i++) {            intj =Biginteger.mod (beginner1). Intvalue (); String S1=Encodegroup (j); if(I > 0) {sb.append ("-");            } sb.append (S1); BigInteger=biginteger.divide (Beginner1); }        returnsb.tostring (); }    /**     * @paramI *@return     */     Public StaticString Encodegroup (inti) {StringBuilder sb=NewStringBuilder ();  for(intj = 0; J < 5; J + +) {            intK = i% 36; CharC; if(K < 10) {C= (Char) (48 +k); } Else{C= (Char) ((+ + k)-10);            } sb.append (c); I/= 36; }        returnsb.tostring (); }    /**     * @paramname *@paramDays *@paramID *@paramPrtype *@return     */     Public StaticString Makekey (string name,intDaysintID) {ID%= 100000; byteBkey[] =New byte[12]; bkey[0] = (byte) 1;//Product Type:intellij idea is 1BKEY[1] = 14;//versionDate d =NewDate (); LongLD = (D.gettime () >> 16); bkey[2] = (byte) (LD & 255); bkey[3] = (byte) ((LD >> 8) & 255); bkey[4] = (byte) ((LD >> +) & 255); bkey[5] = (byte) ((LD >> +) & 255); days&= 0xFFFF; bkey[6] = (byte) (Days & 255); bkey[7] = (byte) ((Days >> 8) & 255); bkey[8] = 105; bkey[9] = 59; bkey[10] = 0; bkey[11] = 0; intw = GETCRC (name, id% 100000, Bkey); bkey[10] = (byte) (W & 255); bkey[11] = (byte) ((w >> 8) & 255); BigInteger POW=NewBigInteger ("89126272330128007543578052027888001981", 10); BigInteger MoD=NewBigInteger ("86f71688cdd2612ca117d1f54bdae029", 16); BigInteger K0=NewBigInteger (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); returnS0; }     Public Static voidMain (string[] args) {if(Args.length = = 0) {System.err.printf ("* * * Usage:%s name%n", keygen.class. Getcanonicalname ()); System.exit (1); } Random R=NewRandom (); System.out.println (Makekey (args[0], 0, R.nextint (100000))); }}

Javac Keygen.java

Java keygen user name

Idea keygen generates key code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.