Build license used to authenticate certificates __java

Source: Internet
Author: User
Tags cos

To build a certificate and put it in a program

FileInputStream fis = new FileInputStream ("Outputlicense.xml");/input
			FileOutputStream fos = new FileOutputStream (" License.enc ")//output
			
			key key = new Encryptiondecryption (). Getkey (Pass_phrase.getbytes ());
			Cipher Cipher = cipher.getinstance ("AES");
			Cipher.init (Cipher.encrypt_mode, key);
	

			Cipher.dofinal (Pass_phrase.getbytes ());

			Save FIS Encryption to the FOS
			cipheroutputstream cos = new CipherOutputStream (FOS, cipher);
			byte[] bytes = new byte[1024];
			while (true) {
				int rc = fis.read (bytes);
				if (rc = = 1) {break
					;
				}
				Cos.write (bytes, 0, RC);
			}
			Fis.close ();
			Cos.flush ();
			Cos.close ();
			Fos.close ();

Certificate of inspection when landing or starting

Key key = new Encryptiondecryption (). Getkey (Pass_phrase.getbytes ());
            Cipher Cipher = cipher.getinstance ("AES");//encryption Method
            Cipher.init (Cipher.decrypt_mode, key);
            InputStream is = new FileInputStream (path+ "License.enc");//encrypted license file
            cipherinputstream cis = new CipherInputStream (IS, cipher);

            int offset = 0;
            byte[] bytes = new byte[2048];
            while (true)
            {
                int rc = cis.read (bytes, offset, bytes.length-offset);
                if (rc = = 1)
                {break
                    ;
                }
                Offset + + rc;
            }
            Is.close ();
            Cis.close ();
            Read into the bean
            properties Licenseprops = new properties ();
            Licenseprops.loadfromxml (New Bytearrayinputstream (bytes, 0, offset));
            license = new license (licenseprops);


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.