/** * INTERNAL: Reads in the infile and writes the encrypted result * into the outfile. */ public static void encrypt(File infile, File outfile) throws IOException { FileInputStream in = new FileInputStream(infile); FileOutputStream out = new FileOutputStream(outfile); encrypt(in, out); in.close(); out.close(); }
/** * INTERNAL: Reads the file into memory, encrypting it in the * process, then writes the encrypted data back out to the file. */ public static void encrypt(File file) throws IOException { FileInputStream in = new FileInputStream(file); ByteArrayOutputStream tmpout = new ByteArrayOutputStream(); encrypt(in, tmpout); in.close(); FileOutputStream out = new FileOutputStream(file); ByteArrayInputStream src = new ByteArrayInputStream(tmpout.toByteArray()); IOUtils.copy(src, out); out.close(); }
public static void main(String[] args) throws java.io.IOException { for (int ix = 0; ix < args.length; ix++) { File arg = new File(args[ix]); File[] files = null; if (arg.isDirectory()) files = arg.listFiles(); else { files = new File[1]; files[0] = arg; } for (int i = 0; i < files.length; i++) { EncryptionUtils.encrypt(files[i]); System.out.println("encrypted module file: " + files[i]); } } } }
protected void createEncryptedFile(String in_name, String out_name) throws IOException { // create encrypted dummy file File in_file = TestFileUtils.getTransferredTestInputFile(testdataDirectory, in_name); File out_file = TestFileUtils.getTestOutputFile(testdataDirectory, out_name); EncryptionUtils.encrypt(in_file, out_file); }