Comments (10)
What is "abnormal"?
from sqliter.
@kpgalligan I'm sorry to have troubled you. What I'm trying to say is not working properly.
from sqliter.
In what way? Doesn't compile? It's not encrypting the data?
from sqliter.
@kpgalligan
It compiles normally. When running on an iPhone, the data is not encrypted. When running in the emulator, the database cannot be opened using the key in the code. I downloaded the generated database to my computer and then tried to open it with DB Browser for SQLite.
from sqliter.
That has nothing to do with sqliter. That's how you're linking to SQLCipher (or whatever you're using).
from sqliter.
I installed SQLCipher correctly.
Call DatabaseConfiguration encryption is normal when Kotlin is set to 1.7.10.
// Project/build.gradle.kts
plugins {
//trick: for the same plugin versions in all sub-modules
id("com.android.application").version("7.4.1").apply(false)
id("com.android.library").version("7.4.1").apply(false)
kotlin("android").version("1.7.10").apply(false)
kotlin("multiplatform").version("1.7.10").apply(false)
}
DatabaseConfiguration encryption goes wrong when Kotlin is set to 1.8.0.
// Project/build.gradle.kts
plugins {
//trick: for the same plugin versions in all sub-modules
id("com.android.application").version("7.4.1").apply(false)
id("com.android.library").version("7.4.1").apply(false)
kotlin("android").version("1.8.0").apply(false)
kotlin("multiplatform").version("1.8.0").apply(false)
}
Android Studio prompts DatabaseConfiguration here:
from sqliter.
You mean SQLCipher does not support Kotlin 1.8.0, not related to DatabaseConfiguration, am I understanding correctly?
from sqliter.
I mean that if you link to sqlite on iOS, you can pass in an encryption key but it won't matter. You need to bundle and link to SQLCipher. It is very hard to figure anything out without seeing your whole config, but basically you need to confirm that you aren't linking to the included sqlite.
How and when do you include SQLCipher on iOS?
from sqliter.
My project uses Kotlin Mulitplatform Mobile and SqlDelight. SQLCipher is used to enhance SQLite for encryption.
I think touchlabSQLiter is the equivalent of middleware, am I getting that right?
Kotlin Mulitplatform Mobile
├── androidMain
├── commonMain
└── iosMain
└── SqlDelight
└── touchlabSQLiter
└── SQLCipher
└── SQLite
Some of my configurations are as follows:
# project/bulid.gradle.kts
plugins {
id("com.android.application").version("7.4.1").apply(false)
id("com.android.library").version("7.4.1").apply(false)
kotlin("android").version("1.7.10").apply(false)
/* The encryption problem occurred in 1.8.0 */
kotlin("multiplatform").version("1.7.10").apply(false)
}
buildscript {
dependencies {
classpath("com.squareup.sqldelight:gradle-plugin:1.5.5")
}
}
# shared/build.gradle.kts
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
id("com.squareup.sqldelight")
}
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0.1"
ios.deploymentTarget = "14.1"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
}
pod("SQLCipher") { /* Call Cocoapods pod install here to install SQLCipher4.5.3 */
version = "~> 4.5.3"
}
}
sourceSets {
val iosArm64Main by getting
val iosX64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosArm64Main.dependsOn(this)
iosX64Main.dependsOn(this)
iosSimulatorArm64Main.dependsOn(this)
dependencies {
implementation("com.squareup.sqldelight:native-driver:1.5.5")
implementation("co.touchlab:sqliter-driver:1.2.1")
}
}
Test equipment:
- iPhone Emulator (iOS15 iPhone8Plus)
- iPhone Real (iOS15.7.2 iPhone7Plus)
- iPhone Real (iOS16.3 iPhone14Pro)
from sqliter.
# shared/iosMain/Kotlin/actual.kt
package me.dxy.common.repository
import co.touchlab.sqliter.DatabaseConfiguration
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver
import com.squareup.sqldelight.drivers.native.wrapConnection
import me.dxy.common.di.MyTestDatabaseWrapper
import me.dxy.mytest.shared.db.MyTestDB
import org.koin.dsl.module
actual fun platformModule() = module {
single {
val schema = MyTestDB.Schema
val databaseConfiguration = DatabaseConfiguration(
name = "testEncrypt.db",
version = schema.version,
create = { connection ->
wrapConnection(connection) { schema.create(it) }
},
upgrade = { connection, oldVersion, newVersion ->
wrapConnection(connection) {
schema.migrate(it, oldVersion, newVersion)
}
},
encryptionConfig = DatabaseConfiguration.Encryption("123")
)
val driver = NativeSqliteDriver(databaseConfiguration)
MyTestDatabaseWrapper(MyTestDB(driver))
}
}
# iosApp/iOSApp.swfit
import SwiftUI
import shared
import SQLCipher
@main
struct iOSApp: App {
init() {
KoinKt.doInitKoin()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
# iosApp/ContentView.swfit
import SwiftUI
import shared
import SQLCipher
struct ContentView: View {
var body: some View {
Text("Oh yeah!")
Button("Click me") {
MyTestRepository().savePeople()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
from sqliter.
Related Issues (20)
- Database file name being created duplicates the last two characters
- Exclude DB from backup/icloud (iOS) HOT 2
- `create` callback invoked only on first connection for in-memory/temporary DBs
- Fix windows and linux builds HOT 3
- Maven coordinate change in 1.3.0 HOT 3
- Add support for androidNative
- Update Kotlin version: 1.9.20 -> 1.9.21
- any docs? HOT 1
- Flaky watchOS test
- Pull error message from sqlite anywhere we have a failure HOT 1
- Review logging
- Kotlin 1.7.20 compatible aarch64 artifacts HOT 2
- SQLiter - 1.8 Beta Testing HOT 6
- SQliter - 1.8 Release Testing HOT 1
- Documentation references
- Support calling `sqlite3_create_collation`
- Cannot run tests on macOS
- in memory DB is not thread-safe
- Support linuxArm64
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqliter.