My esi.getInputStream(fis) actually creates a CipherInputStream with "AES/CBC/NoPadding". This seems to work just fine. BUT when I run this code:
FileInputStream fis = new FileInputStream("MyFile.txt");
FileOutputStream fos = new FileOutputStream("MyFile.cipher");
EncryptionServiceImpl esi = new EncryptionServiceImpl();
CipherInputStream cis = esi.getInputStream(fis);
byte[] bt = new byte[16];
int n;
while ((n = cis.read(bt)) != -1) {
fos.write(bt, 0, n);
}
cis.close();
fos.close();
Only the first 16 bytes get written to the output file. I know that "AES/CBC/NoPadding" means it needs 16 bytes to process...BUT how do you do this when files are always different sizes?! I am basically trying to encrypt and decrypt streams with this algorithm. Ideas?
Thanks!