BuiltInEncryptor implements Encryptor { @Override public void decrypt(String key, File encryptedFile, File decryptedFile) { initCiphers(key); try { CipherOutputStream cos = new CipherOutputStream(new FileOutputStream(decryptedFile), decryptCipher); write(new FileInputStream(encryptedFile), cos); } catch (Exception e) { e.printStackTrace(); } }  @Override void encrypt(String key, File decryptedFile, File encryptedFile); @Override void decrypt(String key, File encryptedFile, File decryptedFile);  }
@Test public void _03_When_Decrypt_Then_Original_Content_Does_Match() { fileOut = getFile(FILENAME_OUT); encryptor.decrypt("key2", fileEncrypted, fileOut); assertEquals(getFileContent(fileIn), (getFileContent(fileOut))); }
@Test public void _04_When_Decrypt_With_Other_Key_Then_Original_Content_Does_Not_Match() { fileOut = getFile(FILENAME_OUT); encryptor.decrypt("keyFail", fileEncrypted, fileOut); assertNotEquals(getFileContent(fileIn), (getFileContent(fileOut))); }
@Test public void _05_When_Decrypt_With_Original_Key_Then_Original_Content_Does_Match() { fileOut = getFile(FILENAME_OUT); encryptor.decrypt("key2", fileEncrypted, fileOut); assertEquals(getFileContent(fileIn), (getFileContent(fileOut))); }