/** 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; }