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);