final File getFile(String source, String destination, byte[] key, long length) {
        try {
            FileInputStream fis = new FileInputStream(source);
            FileOutputStream fos = new FileOutputStream(destination);
            int i = 0;

            SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
            rand.setSeed(key);

            // generate a 128-bit AES key:
            KeyGenerator keyGen = KeyGenerator.getInstance("AES", "BC");
            keyGen.init(128, rand);
            Key fileKey = keyGen.generateKey();

            if(length == -1) {
                FileCipher.init(Cipher.ENCRYPT_MODE, fileKey, encrFileIV);
            } else {
                FileCipher.init(Cipher.DECRYPT_MODE, fileKey, encrFileIV);
            }

            CipherOutputStream cos = new CipherOutputStream(fos, FileCipher);
            
            while(true) {
                i = fis.read();
                if(i == -1)
                    break;
                cos.write(i);
            }

            cos.flush();
            cos.close();
            fis.close();
        } catch(Exception e) {
            e.printStackTrace();
        }

        return new File(destination);
            /*
            HexString hex = new HexString();
            //System.out.println("source=" + source + "\ndest=" + destination + "\nlength=" + length);

            String s = "This is a string";
            byte[] b = s.getBytes();
            s = hex.toHexString(b);
            System.out.println(s);
            b = s.getBytes();
            s = new String(b);
            b = s.getBytes();
            s = hex.toHexString(b);
            System.out.println(s);
            b = hex.toByteArray(s);
            s = new String(b);


            FileInputStream fis = new FileInputStream(source);
            //BufferedInputStream bin = new BufferedInputStream(fis);
            FileOutputStream fos = new FileOutputStream(destination);
            if(length != -1)
                length = bin.available();

            SecureRandom rand = SecureRandom.getInstance("SHA1PRNG");
            rand.setSeed(key);

            // generate a 128-bit AES key:
            KeyGenerator keyGen = KeyGenerator.getInstance("AES", "BC");
            keyGen.init(128, rand);
            Key fileKey = keyGen.generateKey();

            int len = 0;
            byte[] buffer = new byte[128];

            if(length == -1) {
                length = fis.available();
                FileCipher.init(Cipher.ENCRYPT_MODE, fileKey, groupIV);
                CipherInputStream cis = new CipherInputStream(bin, FileCipher);
                //String tmp = "";
                
                while ((len = cis.read(buffer)) > 0) {
                    //tmp = hex.toHexString(buffer);
                    fos.write(buffer, 0, len);
                    length -= len;
                }
                
                cis.close();
                fos.close();
            } else {
                FileCipher.init(Cipher.DECRYPT_MODE, fileKey, groupIV);
                BufferedOutputStream bout = new BufferedOutputStream(fos);
                //CipherOutputStream out = new CipherOutputStream(bout, FileCipher);
                String tmp = "";
                length = (long)fis.available();
                //System.out.println(source + " is " + length + " long");
                while (length > 0) {
                    len = bin.read(buffer);
                    if (len < 0) {
                        break;
                    }
                    //tmp = hex.toHexString(buffer);
                    //buffer = tmp.getBytes();
                    //bout.write(buffer, 0, len);
                    //System.out.println("buffer=" + new String(buffer));
                    if (length < buffer.length) {
                        bout.write(FileCipher.doFinal(buffer, 0, len));
                    } else {
                        bout.write(FileCipher.update(buffer, 0, len));
                    }

                    //buffer = new byte[128];

                    length -= len;
                }

                bout.flush();
                bout.close();
                fis.close();
            }
            
                //CipherOutputStream out = new CipherOutputStream(fos, AEScipher);

                //int len = 0;
                //byte[] buffer = new byte[128];
                while ((len = bin.read(buffer)) > 0) {
                    out.write(buffer, 0, len);
                //System.err.println(new String(buffer));
                }
             
                //out.flush();
                //out.close();
                //bin.close();
            //}
        } catch(Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
        return new File(destination);*/
    }