Persist notification big pictures encrypted

This commit is contained in:
ajp_anton
2026-07-23 10:23:49 +00:00
parent 9e917eacd3
commit 8570f65d09
3 changed files with 33 additions and 0 deletions
@@ -0,0 +1,19 @@
package se.ajpanton.notificationlog.data
import android.content.Context
import java.io.File
/** Stores copied notification image bytes independently of the source app's URI lifetime. */
class EncryptedImageStore(context: Context) {
private val directory = File(context.filesDir, "notification-images").also(File::mkdirs)
private val cipher = AesGcmCipher(LogEncryptionKeyProvider().getOrCreate())
fun save(id: String, bytes: ByteArray) {
val payload = cipher.encrypt(bytes)
File(directory, "$id.bin").outputStream().use { output ->
output.write(payload.initializationVector.size)
output.write(payload.initializationVector)
output.write(payload.cipherText)
}
}
}