Results 1 to 20 of 24

Thread: Protecting SQLite Data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Protecting SQLite Data

    Works fine for me. You are using the Sqlcipher version of sqlite3, aren't you?

    Qt Code:
    1. // First, a freshly built sqlcipher
    2. chrisw@newton /tmp/sqlcipher $ ./sqlite3 plain.db
    3. SQLite version 3.7.2
    4. Enter ".help" for instructions
    5. Enter SQL statements terminated with a ";"
    6. sqlite> create table data(a integer);
    7. sqlite> insert into data values (1);
    8. sqlite> insert into data values (2);
    9. sqlite> insert into data values (3);
    10. sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'secret';
    11. sqlite> create table encrypted.data as select * from data;
    12. sqlite> select * from encrypted.data;
    13. 1
    14. 2
    15. 3
    16. sqlite> .q
    17.  
    18. // See that the encrypted file is not identified as Sqlite
    19. chrisw@newton /tmp/sqlcipher $ file plain.db encrypted.db
    20. plain.db: SQLite 3.x database
    21. encrypted.db: data
    22.  
    23. // And that the data is there
    24. chrisw@newton /tmp/sqlcipher $ ./sqlite3 encrypted.db
    25. SQLite version 3.7.2
    26. Enter ".help" for instructions
    27. Enter SQL statements terminated with a ";"
    28. sqlite> pragma key = "secret";
    29. sqlite> .tables
    30. data
    31. sqlite> select * from data;
    32. 1
    33. 2
    34. 3
    35. sqlite> .q
    36.  
    37. // Now with the system, non-encrypting sqlite3
    38. chrisw@newton /tmp/sqlcipher $ /usr/bin/sqlite3 encrypted.db
    39. SQLite version 3.7.2
    40. Enter ".help" for instructions
    41. Enter SQL statements terminated with a ";"
    42. sqlite> .tables
    43. Error: file is encrypted or is not a database
    44. sqlite> .q
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to ChrisW67 for this useful post:

    zim (24th February 2011)

Similar Threads

  1. Qt to Sqlite data insertion doubt.
    By rex in forum Qt Programming
    Replies: 15
    Last Post: 16th December 2010, 12:31
  2. Replies: 13
    Last Post: 6th December 2010, 04:41
  3. Sqlite and UTF8 data
    By kroenecker in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2009, 14:49
  4. data not being retained in sqlite DB
    By sticcino in forum Qt Programming
    Replies: 2
    Last Post: 2nd July 2008, 10:42
  5. Write protecting cells
    By therealjag in forum Qt Programming
    Replies: 2
    Last Post: 12th February 2006, 09:47

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.