LoginSignup
13
19

More than 5 years have passed since last update.

SQLiteの暗号化

Last updated at Posted at 2017-12-27

SQLiteを利用するにあたって、最低限の暗号化くらいはかけておかないとくらいの気持ちで調べたときのまとめ

前提として

  • sqlite3_keyを使いたい

DBを開いてパスフレーズを設定するだけで暗号化できるとのこと

sqlite3_open( "test.db", &db );
sqlite3_key( "pass", ( int )strlen( "pass" ) );

なお、パスフレーズは64文字の16進数であると動作が速くなるとのこと
参考:cocos2d-x ローカルデータの暗号化、SQLCipherを爆速化する方法

  • ios, android, windowsで動作する
  • 無償

暗号化する方法について調べた

参考:SQLite with encryption/password protection

  • SEE - The official implementation.
  • wxSQLite - A wxWidgets style C++ wrapper that also implements SQLite's encryption.
  • SQLCipher - Uses openSSL's libcrypto to implement.
  • SQLiteCrypt - Custom implementation, modified API.
  • botansqlite3 botansqlite3 is an encryption codec for SQLite3 that can use any algorithms in Botan for encryption.
  • SQLiteCrypto - SQLiteCrypto is The Easier Way To Encrypt Sqlite Database By AES-256 and SHA-256

日本語ドキュメントの件数だとSQLCipher>wxSQLite>その他って感じ

SQLCipher

  • 無償で使うにはソースからビルドする必要がある
  • iOSのドキュメントは結構豊富(参考:【c++】SQLCipherを導入してみた
  • 静的ライブラリのリビルド必要(BitCode対応してない!)
  • AndroidとWindowsどうしよう(そもそもCで書かれたソースリンクするだけがいいんだが)

という感じで断念

wxSQLite

Cのソースをリンクするだけでいけそう(いけた)
SQLCipherを導入しようとあれこれがんばっていた時間はなんだったんだ・・・というくらい素早くいけました
参考:SQLite の暗号化

13
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
19