How to encrypt the SQLite database in Flutter?

两盒软妹~` 提交于 2019-11-29 22:17:36

问题


I am creating a database in Flutter by the following code, is there any way we can encrypt the database?

Is there any library available for Flutter?

initDb() async {
    io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
    String path = join(documentsDirectory.path, "test.db");
    var theDb = await openDatabase(path, version: 1, onCreate: _onCreate);
    return theDb;
  }

回答1:


Pointy Castle seems to be the encryption library of choice at the moment.




回答2:


Current sqflite uses whatever sqlite version the platform provides. There is a discussion about that here that you could follow here: https://github.com/tekartik/sqflite/issues/32

The only solution I am aware now is this one https://github.com/QwilApp/encrypted_sqlite which can be used as a drop-in replacement to sqflite which as you stated uses SQLCipher on the native side




回答3:


I am also looking for such a library today.

And finally I found flutter_sqlcipher in pub.dev, which really solved my problem.

Here is the description of it.

This is a Flutter plugin that bundles and wraps SQLCipher for Android, an open-source extension to SQLite that provides transparent 256-bit AES encryption of database files.

Hope it helps you.



来源:https://stackoverflow.com/questions/50232418/how-to-encrypt-the-sqlite-database-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!