@Test public void shouldDecryptStream() throws Exception { File out = File.createTempFile("db-test", ".sql"); FileOutputStream fos = new FileOutputStream(out); dbDecryptor.decryptStream(new FileInputStream(Fixtures.TEST_DB_1), fos); verifyDB(out); }
protected void decryptStream(InputStream in, OutputStream out) throws GeneralSecurityException, IOException { Cipher cipher = getCipher(Cipher.DECRYPT_MODE); CipherInputStream cis = null; try { cis = new CipherInputStream(in, cipher); byte[] buffer = new byte[8192]; int n; while ((n = cis.read(buffer)) != -1) { out.write(buffer, 0, n); } } finally { try { if (cis != null) cis.close(); out.close(); } catch (IOException ignored) {} } }
DBDecryptor implements Decryptor { protected void decryptStream(InputStream in, OutputStream out) throws GeneralSecurityException, IOException { Cipher cipher = getCipher(Cipher.DECRYPT_MODE); CipherInputStream cis = null; try { cis = new CipherInputStream(in, cipher); byte[] buffer = new byte[8192]; int n; while ((n = cis.read(buffer)) != -1) { out.write(buffer, 0, n); } } finally { try { if (cis != null) cis.close(); out.close(); } catch (IOException ignored) {} } } }
DBDecryptor implements Decryptor { protected void decryptStream(InputStream in, OutputStream out) throws GeneralSecurityException, IOException { Cipher cipher = getCipher(Cipher.DECRYPT_MODE); CipherInputStream cis = null; try { cis = new CipherInputStream(in, cipher); byte[] buffer = new byte[8192]; int n; while ((n = cis.read(buffer)) != -1) { out.write(buffer, 0, n); } } finally { try { if (cis != null) cis.close(); out.close(); } catch (IOException ignored) {} } }  }
DBDecryptor implements Decryptor { protected void decryptStream(InputStream in, OutputStream out) throws GeneralSecurityException, IOException { Cipher cipher = getCipher(Cipher.DECRYPT_MODE); CipherInputStream cis = null; try { cis = new CipherInputStream(in, cipher); byte[] buffer = new byte[8192]; int n; while ((n = cis.read(buffer)) != -1) { out.write(buffer, 0, n); } } finally { try { if (cis != null) cis.close(); out.close(); } catch (IOException ignored) {} } }  void decryptDB(File input, File output); static void main(String[] args); }
DBDecryptor implements Decryptor { protected void decryptStream(InputStream in, OutputStream out) throws GeneralSecurityException, IOException { Cipher cipher = getCipher(Cipher.DECRYPT_MODE); CipherInputStream cis = null; try { cis = new CipherInputStream(in, cipher); byte[] buffer = new byte[8192]; int n; while ((n = cis.read(buffer)) != -1) { out.write(buffer, 0, n); } } finally { try { if (cis != null) cis.close(); out.close(); } catch (IOException ignored) {} } }  void decryptDB(File input, File output); static void main(String[] args);  }