Which encrypted SQLite database to use?

Currently I am using Cordova-sqlite-storage for my mobile app via this angular wrapper provided by ngCordova but I also require to have an encrypted SQLite database for which I found Cordova-sqlcipher-adapter but it is known to have issues and their is no ngCordova plugin for it either. Any other possibilties?

1 Like

Not that I’ve found but would be interested in alternatives too.

The only issue I’m aware of is that it doesn’t play nice with Crosswalk and I can’t say I’ve noticed any problems using it so far.

As for lack of plugin it still can be used successfully within Ionic / Angular as long as you handle the digest cycle (scope.apply() etc) correctly.

@bmwilson74, Can you please provide me the link to work with sqlcipher? I have tried, but I unable to find the link for sqlcipher with cordova.


@mohanapriya I’ve used
https://github.com/litehelpers/Cordova-sqlcipher-adapter and had no issues
on iOS or Android 4.4+ so far.

@Ben, Thanks for your replay. I have installed the plugin. Can you tell me how to use a key to open sql database which helps to do encryption and decryption?c

See https://github.com/litehelpers/Cordova-sqlcipher-adapter in section
’Opening a database’. In brief its just:

var db = window.sqlitePlugin.openDatabase({name: ‘my.db’, key:
‘your-password-here’, location: ‘default’}, successcb, errorcb);

I am using ionic 1
using the same code mentioned above to create db but when I inspect app in chrome and write a select query data result shows plain data, data is not yet all encrypted

… because you opened the connection using the right key. So your code simply works.

Where do I need to register a key for encryption, could you please send a detailed info

Where do I need to register a key for encryption, could you please send a detailed info

  • When a database connection is attempted for the first time (nonexistent database), the key will be used to encrypt new database file and the connection will always be successful.
  • When a database connection is attempted on an existing database, the key will be used to decrypt the database file, so it has to match with the key you used for the first connection otherwise the connection cannot be opened.

There’s no need to register the key somewhere else.

Now I am unable to open database in stetho, so encryption is working. But in the app all inserts on this encrypted database are failing with following error

“Populate table error: a statement with no error handler failed: error code 8: attempt to write a readonly database”