3232An [ SQLDelight] [ url-sqldelight ] driver that uses [ SQLite3MultipleCiphers] [ url-sqlitemc ] for
3333database encryption.
3434
35-
36-
3735### Usage
3836
3937- Define ` DatabasesDir `
@@ -89,7 +87,7 @@ database encryption.
8987 put(" busy_timeout" , 3_000 .toString())
9088
9189 // ephemeral connections only
92- ephemeral.put(" secure_delete" , " false" )
90+ ephemeral.put(" secure_delete" , false .toString() )
9391
9492 // filesystem connections only
9593 filesystem.put(" secure_delete" , " fast" )
@@ -118,6 +116,7 @@ database encryption.
118116
119117- Easily spin up an ephemeral database for your configuration (no encryption)
120118 ``` kotlin
119+ // NOTE: Suspension function "create" alternative available
121120 val inMemoryDriver = factory.createBlocking(opt = EphemeralOpt .IN_MEMORY )
122121 val namedDriver = factory.createBlocking(opt = EphemeralOpt .NAMED )
123122 val tempDriver = factory.createBlocking(opt = EphemeralOpt .TEMPORARY )
@@ -129,17 +128,20 @@ database encryption.
129128- Easily change ` Key ` s
130129 ``` kotlin
131130 // NOTE: Suspension function "create" alternative available
132- val driver2 = factory.createBlocking(
133- key = Key .passphrase(" password" ),
134- rekey = Key .passphrase(" new password" ),
135- )
131+ val driver2 = factory.createBlocking(key = Key .passphrase(" password" ), rekey = Key .passphrase(" new password" ))
136132 driver2.close()
137133
134+ // Remove encryption entirely by passing an empty key (i.e. Key.passphrase(""))
135+ val driver3 = factory.createBlocking(key = key.passphrase(" new password" ), rekey = Key .Empty )
136+ driver3.close()
137+
138138 // Also supports use of RAW (already derived) keys and/or salt storage for SQLCipher & ChaCha20
139- val (derivedKey, salt) = deriveMy32ByteKeyAnd16ByteSalt(" secret password" ) // however you want to do it
139+ val salt = getOrCreate16ByteSalt(" user abc" )
140+ val derivedKey = derive32ByteKey(salt, " user secret password input" )
140141 val rawKey = Key .raw(key = derivedKey, salt = salt, fillKey = true )
141142
142- val driver3 = factory.createBlocking(key = Key .passphrase(" new password" ), rekey = rawKey)
143+ val driver4 = factory.createBlocking(key = Key .Empty , rekey = rawKey)
144+ driver4.close()
143145 ```
144146
145147- Easily migrate encryption configurations between software releases by defining a migrations block
@@ -155,9 +157,9 @@ database encryption.
155157
156158 // Simply move your old encryption config up to a migration.
157159 //
158- // Do note that if you _are_ migrating from SQLCipher library,
159- // the version of SQLCipher used the first time your app was
160- // published with it. You will _also_ need to define migrations
160+ // If you _are_ migrating from SQLCipher library, note the
161+ // version of SQLCipher used the first time your app was
162+ // published with it. You will also need to define migrations
161163 // all the way back for each possible version (v1, v2, v3),
162164 // so that users who have not opened your app in a long time
163165 // can migrate from those versions as well.
@@ -363,44 +365,37 @@ I'm guessing this is not really a factor on iOS."
363365
364366<!-- TAG_VERSION -->
365367
366- Currently, this library is still under heavy construction.
367-
368- A ` -SNAPSHOT ` will be released in order to hone the API while
369- integrating it into some other projects I am building this for,
370- after which an ` -alpha01 ` release will follow.
371-
372- <!--
373- **Set `linkSqlite` to false**
374- ```kotlin
375- sqldelight {
376- linkSqlite.set(false) // <<--- must be false if using native
377-
378- databases {
379- // ...
380- }
381- }
382- ```
383-
384- **Add dependencies**
385- ```kotlin
386- dependencies {
387- val sqliteMC = "2.0.0-1.6.4-0-SNAPSHOT"
388-
389- // NOTE: Remove dependencies on the following if you have them
390- // - "app.cash.sqldelight:sqlite-driver"
391- // - "app.cash.sqldelight:native-driver"
392-
393- implementation("io.toxicity.sqlite-mc:driver:$sqliteMC")
394-
395- // For android unit tests (NOT instrumented)
396- // This is simply the desktop binary resources needed for JDBC
397- testImplementation("io.toxicity.sqlite-mc:android-unit-test:$sqliteMC")
398- }
399- ```
400- -->
368+ 1 . Remove ` SQLDelight ` gradle plugin and drivers from your project
369+ 2 . Apply the ` sqlite-mc ` gradle plugin.
370+ ``` kotlin
371+ plugins {
372+ // Provides the SQLDelight gradle plugin automatically and applies it
373+ id(" io.toxicity.sqlite-mc" ) version(" 2.0.0-1.7.2-0-alpha01" )
374+ }
375+
376+ // Will automatically:
377+ // - Configure the latest SQLite dialect
378+ // - Add the sqlite-mc driver dependency
379+ // - Link native targets for provided SQLite3MultipleCiphers binaries
380+ sqliteMC {
381+ databases {
382+ // Configure just like you would the SQLDelight plugin
383+ }
384+ }
385+ ```
386+ 3 . If you have Android unit tests
387+ ``` kotlin
388+ dependencies {
389+ // For android unit tests (NOT instrumented)
390+ //
391+ // This is simply the desktop binary resources needed for
392+ // JDBC to operate locally on the machine.
393+ testImplementation(" io.toxicity.sqlite-mc:android-unit-test:2.0.0-1.7.2-0-alpha01" )
394+ }
395+ ```
401396
402397<!-- TAG_VERSION -->
403- [ badge-latest-release ] : https://img.shields.io/badge/latest--release-2.0.0--1.7.2--0--SNAPSHOT -blue.svg?style=flat
398+ [ badge-latest-release ] : https://img.shields.io/badge/latest--release-2.0.0--1.7.2--0--alpha01 -blue.svg?style=flat
404399[ badge-license ] : https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat
405400
406401<!-- TAG_DEPENDENCIES -->
0 commit comments