You're prompted for a passphrase (should be at least 8 characters long.
Real-life apps should enforce a more strict
passphrase strength
policy).
If the file testsqlcipher.db
doesn't exist, it will be created
with this passphrase, otherwise - the passphrase should match
the existing db (or it can't be decrypted [hopefully]).
You can also access the database with an iteractive sqlcipher shell,
sqlite> pragma key = 'alongenoughpassphrase';
sqlite> pragma kdf_iter = 64000;
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE "person" ("name" VARCHAR(255) NOT NULL PRIMARY KEY, "age" INTEGER NOT NULL);
INSERT INTO "person" VALUES('alice',17);
INSERT INTO "person" VALUES('bob',23);
INSERT INTO "person" VALUES('carol',42);
COMMIT;
or import testpeeweesqlcipher
into python and use a()
and q()
.
>>> from testpeeweesqlcipher import *
Passphrase:
That's not a good passphrase... Sorry.
Passphrase:
Wrong passphrase... Sorry.
Passphrase:
>>> a("ted",64)
('INSERT INTO "person" ("name", "age") VALUES (?, ?)', [u'ted', 64])
<Person: u'ted (age 64)'>