/** Wraps the input stream if it needs to be decrypted. */ InputStream decrypt(InputStream in) throws IOException { if (mCrypto != null) { try { in = mCrypto.newDecryptingStream(0, in); } catch (GeneralSecurityException e) { throw new DatabaseException(e); } } return in; }
/** Wraps the output stream if it needs to be encrypted. */ OutputStream encrypt(OutputStream out) throws IOException { if (mCrypto != null) { try { out = mCrypto.newEncryptingStream(0, out); } catch (GeneralSecurityException e) { throw new DatabaseException(e); } } return out; }