Skip to content

How to check pragma key is correct or incorrect? #3332

Answered by simolus3
ayyyushhhhh asked this question in Q&A
Discussion options

You must be logged in to vote

Your snippet didn't use the temporary database, did you do something like this / did that find the wrong key?

  static void openDatabase(String key) async {
    final path = await getApplicationDocumentsDirectory();
    Database db = sqlite3.open(File('${path.path}/mentcura.db.enc').path);
    try {
      db.execute('pragma key = ?', [key]);
      db.execute('select count(*) from sqlite_master');
    } on SqliteException catch (e) {
      print('Likely a wrong key: $e');
    } finally {
      db.dispose();
    }

    NativeDatabase.opened(
      db,
      setup: (database) {
        database.execute("PRAGMA key = '$key';");
        db.execute('select count(*) from sqlite_master');
      }…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
8 replies
@simolus3
Comment options

@ayyyushhhhh
Comment options

@simolus3
Comment options

Answer selected by ayyyushhhhh
@ayyyushhhhh
Comment options

@simolus3
Comment options

@ayyyushhhhh
Comment options

@simolus3
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants