I'm trying to encrypt the KMP's room DB for androi...
# room
m
I'm trying to encrypt the KMP's room DB for android and iOS using SQLCipher. For android, I can get it done by the openHelperFactory
Copy code
internal fun getDatabaseBuilder(app: Application): RoomDatabase.Builder<MyDatabase> {
    val passphrase: ByteArray = SQLiteDatabase.getBytes("temp_passphrase".toCharArray())
    val factory = SupportFactory(passphrase)
    val dbFile = app.getDatabasePath(KMPConstants.DB_FILE_NAME)
    return Room.databaseBuilder<MyDatabase>(
        context = app,
        name = dbFile.absolutePath,
    )
        .openHelperFactory(factory)
}
How do I do it for iOS?
d
It should be possible to grab SQLCipher's source (
sqlite3.c
) and compile it for iOS and create a
SQLiteDriver
that Room can use. This is what I did in this sample driver but with Android: https://github.com/danysantiago/androidx-driver-samples/tree/main/sqlcipher-driver