· 9 years ago · Nov 04, 2016, 12:18 PM
1FileOutputStream out = new FileOutputStream("output.txt");
2 String key="12345678";
3
4 DESKeySpec des=new DESKeySpec(key.getBytes());
5 SecretKeyFactory s= SecretKeyFactory.getInstance("DES");
6 SecretKey key1= s.generateSecret(des);
7
8 Cipher c= Cipher.getInstance("DES");
9 c.init(Cipher.ENCRYPT_MODE,key1);
10 CipherInputStream in= new CipherInputStream(new FileInputStream("input.txt"), c);
11 int temp = in.read();
12 while(temp!=-1){
13 temp=in.read();
14 out.write(temp);
15 }
16 in.close();
17 out.close();