I am currently working on an android application that stores sensitive documents that are encrypted on the device. When the user opens the document it decrypts it and displays it to them. I have figured out the encryption I am just not sure how to display it without saving the decrypted file and then displaying it. Is there a way to send the CipherOutputStream to the pdf renderer? Is there a way to do this or do I just have to use a cache file and is that secure? Or do I have to build my own pdf renderer for this?
This is how I am decrypting the pdf
val cipher = Cipher.getInstance("AES/ECB/PKCS5Padding")
val inputStream = context.openFileInput(fileNameToConvert)
val outputCacheFile = File(context.cacheDir, nameDecryptedFileToSave)
cipher.init(Cipher.DECRYPT_MODE, key)
CipherOutputStream(outputCacheFile.outputStream(), cipher).use {
it.write(inputStream.readBytes())
}