Hi,
So on the Wiki for the encryption support in CBL on iOS and Mac, it says:
It's not yet possible to add encryption to an existing database, or to
> change or remove the key afterwards.
Do you think this will be possible anytime soon? SQLCipher has a migration
system built-in to migrate an unencrypted database to an encrypted
database. It's quite straight forward actually:
Using the following commands you can encrypt a database (given the path to
the database and an encryption key):
sqlite3_exec([db sqliteHandle], [[[NSString alloc] initWithFormat:@"attach
database '%@' as encrypted key '%@';", escapedPath, escapedKey] UTF8String],
NULL, NULL, NULL);
rc = sqlite3_exec([db sqliteHandle], [@"SELECT
sqlcipher_export('encrypted');" UTF8String], NULL, NULL, NULL);
You can do the reverse easily enough by removing the key and exporting
again:
rc = sqlite3_exec([db sqliteHandle], [[[NSString alloc] initWithFormat:@"attach
database '%@' as plain key '';", escapedPath] UTF8String], NULL, NULL, NULL
);
rc = sqlite3_exec([db sqliteHandle], [@"SELECT sqlcipher_export('plain');"
UTF8String], NULL, NULL, NULL);
And for changing the key, it's just:
int rc = sqlite3_rekey(_db, [keyData bytes], (int)[keyData length]);
If it won't be implemented in CouchbaseLite, do you think it would be ok to
just hit the sqlite file outside of CouchbaseLite and do it myself?
Obviously closing the database from CBLManager first before doing that.
Thanks,
Brendan
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/1f0f266b-9d8b-4c52-8adb-678eb783cf0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.