1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| /** Encrypt a file **/
String clearFile = in.readLine();
String encrFile = "simpsons.ciphered";
try {
FileInputStream fis = new FileInputStream( clearFile );
FileOutputStream fos = new FileOutputStream( encrFile );
CipherOutputStream cphout = new CipherOutputStream( fos, c );
byte [] byteBuff = new byte [ 8196 ];
int bytesRead = fis.read( byteBuff );
while ( bytesRead != -1 ) {
cphout.write( byteBuff, 0, bytesRead );
bytesRead = fis.read( byteBuff );
}
cphout.close ( );
fis.close ( );
fos.close ( );
}
catch( IOException iox ) {
System.out.println( iox );
} |
Partager