我有过逆向工程的经验,人们可以在 android 中流畅地访问您的数据库。我想知道有什么方法可以在创建时只加密我的数据库(不混淆整个 apk),然后在运行时我会使用我的数据库。
我对数据库的了解较少,因此任何建议都可以保护我在资产文件夹中的数据库。
You cannot secure information contained on the App. It's impossible.
An attacker can reverse all of your code.
An attacker can deobfuscate all of your code.
A preloaded, encrypted DB file can be decrypted using the key stored on the App.
Particularly in code like this:
String dbPath = this.getDatabasePath("Encrypted.db").getPath();
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbPath,
**DATABASEKEY**, null);
SQLCipher is not intended to secure user data against attackers but exists to secure user data against other Apps.
Your efforts will slow an attacker down slightly.
If you want to sensitive data on the App, don't store it on the App or in the data directory. Design your App to communicate with a server, although that bring in a whole other mess of things to consider (Web App Security).
也许对您存储在表中而不是整个表中的字符串进行加密会更可行。例如存储密码的哈希值而不是直接存储它们..
你看过Proguard吗?
ProGuard 工具通过删除未使用的代码并用语义模糊的名称重命名类、字段和方法来缩小、优化和混淆您的代码。结果是较小的 .apk 文件更难进行逆向工程。因为 ProGuard 使您的应用程序更难逆向工程
有关proguard的更多信息。