【发布时间】:2018-02-15 04:04:03
【问题描述】:
现在我正在使用 OrmLite 而不是带有 SQLCipher 的 SQLite。 难道真的没有办法保护Room数据库不被读取???
【问题讨论】:
-
见
android.arch.persistence.db.SupportSQLiteOpenHelper
标签: android android-room
现在我正在使用 OrmLite 而不是带有 SQLCipher 的 SQLite。 难道真的没有办法保护Room数据库不被读取???
【问题讨论】:
android.arch.persistence.db.SupportSQLiteOpenHelper
标签: android android-room
Room 默认将数据存储在应用程序的内部存储中,任何 root 用户都可以访问。
如果您需要一些安全性,您需要使用像 cwac-saferoom 这样的加密库。
【讨论】:
1.0.0,我现在在1.0.0-alpha3,除非有人发现漏洞,否则1.0.0 将在月底发布。
Android 的 SQLCipher 现在直接支持 Room。你可以找到文档here
因此,@CommonsWare 将不再积极开发cwac-saferoom,并建议使用 SQLCipher 的支持
【讨论】:
Android Room DB 明确不支持加密。一个典型的 未加密的 SQLite 数据库。您可以将 SQLCipher for Android 与 Room 或 androidx.sqlite API 的其他使用者来保护您的数据 存储在 sqlite 数据库中。 QLipher 有一个
SupportFactory类在 可用于配置 Room 的net.sqlcipher.database包 使用适用于 Android 的 SQLCipher。查看标准 SQLite 数据库的 hexdumps 和一个实现 SQLCipher。
~ sjlombardo$ hexdump -C sqlite.db
00000000 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 |SQLite format 3.|
…
000003c0 65 74 32 74 32 03 43 52 45 41 54 45 20 54 41 42 |et2t2.CREATE TAB|
000003d0 4c 45 20 74 32 28 61 2c 62 29 24 01 06 17 11 11 |LE t2(a,b)$…..|
…
000007e0 20 74 68 65 20 73 68 6f 77 15 01 03 01 2f 01 6f | the show…./.o|
000007f0 6e 65 20 66 6f 72 20 74 68 65 20 6d 6f 6e 65 79 |ne for the money|
~ $ sqlite3 sqlcipher.db
sqlite> PRAGMA KEY=’test123′;
sqlite> CREATE TABLE t1(a,b);
sqlite> INSERT INTO t1(a,b) VALUES (‘one for the money’, ‘two for the show’);
sqlite> .quit
~ $ hexdump -C sqlcipher.db
00000000 84 d1 36 18 eb b5 82 90 c4 70 0d ee 43 cb 61 87 |.?6.?..?p.?C?a.|
00000010 91 42 3c cd 55 24 ab c6 c4 1d c6 67 b4 e3 96 bb |.B?..?|
00000bf0 8e 99 ee 28 23 43 ab a4 97 cd 63 42 8a 8e 7c c6 |..?(#C??.?cB..|?|
~ $ sqlite3 sqlcipher.db
sqlite> SELECT * FROM t1;
Error: file is encrypted or is not a database
【讨论】: