Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1

Thread: AES Encryption

  1. #1
    New Coder
    Join Date
    Oct 2009
    Thanked 2 Times in 2 Posts

    AES Encryption

    I find it neccesary to add a new layer of protection; AES Encryption i have written all of the code for the encryption process but it throws an exception that either the key's size is to large or that the default parameters are incorrect.

    Issue #1
                            byte[] key = ...... //secret, the byte array has a total of 32 bytes.
                            SecretKeySpec k = new SecretKeySpec(key, "AES");
    			byte[] input = getBytesOfFile(encrypter.current);
    			Cipher cipher = Cipher.getInstance("AES");
    			cipher.init(Cipher.ENCRYPT_MODE, k);
    			byte[] encryptedData = cipher.doFinal(input);

    In PHP i use readfile in combination with a few headers (including) binary to forward any .jar file to java.
    How would i read this in Java and then convert all the bytes to JarFile.

    	private class internalLoader extends ClassLoader {
    		public Class<?> clazz;
    		public internalLoader(byte[] bytes) {
    			this.clazz = defineClass(selectedScript, bytes, 0, bytes.length);
    		private void proceed() {
    			try {
    				script = (Script) clazz.asSubclass(Script.class).newInstance();
    			} catch (Exception e) {
    	private byte[] inputStreamToByteArray(InputStream input) throws IOException {
    		ByteArrayOutputStream output = new ByteArrayOutputStream(1024);
    		byte[] buffer = new byte[512];
    		int bytes;
    		while ((bytes = input.read(buffer)) > 0) {
    			output.write(buffer, 0, bytes);
    		return output.toByteArray();
    				byte[] bytes = inputStreamToByteArray((loaderConnection
    				new internalLoader(bytes);
    Last edited by BinaryX; 01-26-2011 at 02:50 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts