private static void doCrypt(String in, String out, String pass, boolean encrypt, String encoding) throws IOException, InvalidEncodingException {
        Cryptographer crypt = new CBCCryptographer();
        CryptographerHandler bm = new CryptographerHandler(crypt);
        verbosePrint("Using "+bm.getCryptoMode());
        CryptStatus result = null;

        verbosePrint("Opening file: " + in);
        try {
            bm.openFile(new File(in));
        }
        catch (OutOfMemoryError oome) {
            System.err.println("Error: Out Of Memory! File too large");
            System.exit(1);
        }


        Encoding enc = Encoding.toEnum(encoding);
        if(!encoding.equals("default")) {
            if(enc == null) {
                throw new InvalidEncodingException("Invalid encoding: " + encoding);
            }
            else {
                verbosePrint("Setting encoding to: "+enc.toString());
                bm.setEncoding(enc);
            }
        }


        if (pass == null) {
            System.out.print("Enter password: ");

            //Attempt to hide password input. Only works if the program is run from a true console
            //Running from an IDE won't return a Console object, use Scanner in this case.
            Console c = System.console();
            try {
                pass = new String(c.readPassword());
            } catch (NullPointerException npe) {
                pass = new Scanner(System.in).nextLine();
            }

        }
        try {
            if (encrypt) {
                verbosePrint("Encrypting...");
                result = bm.encrypt(pass);
            } else {
                verbosePrint("Decrypting...");
                result = bm.decrypt(pass);
            }
        }
        catch (OutOfMemoryError oome) {
            System.err.println("Error: Out Of Memory! File too large");
            System.exit(1);
        }
        if(result.equals(CryptStatus.DECRYPT_SUCCESS) || result.equals(CryptStatus.ENCRYPT_SUCCESS)) {
            verbosePrint("Saving to: "+out);
            bm.saveFile(new File(out));
        }
        System.out.println(result.toString());

    }