import java.security.*; import javax.crypto.*; import java.io.*; public class EncryptHandler { // public static void main(String args[]) { try { //secrekKey FileInputStream fis = new FileInputStream(args[1]); ObjectInputStream ois = new ObjectInputStream(fis); //encryptedData FileOutputStream fos = new FileOutputStream(args[2]); SecretKey key = (SecretKey)ois.readObject(); ois.close(); fis.close(); Cipher c = Cipher.getInstance("Blowfish/ECB/PKCS5Padding"); c.init(Cipher.ENCRYPT_MODE, key); CipherInputStream cis = new CipherInputStream(new FileInputStream(args[0]), c); byte[] b = new byte[8]; int i = cis.read(b); while (i != -1){ fos.write(b, 0, i); i = cis.read(b); } cis.close(); fos.close(); }catch(Exception e){ e.printStackTrace(); } } }