加密Android中已有的数据库 [英] Encrypt exisiting database in Android

查看:394
本文介绍了加密Android中已有的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序已发表在Play商店。现在,我希望应用程序的数据库进行加密。

I have an app already published in Play Store. Now, I want to encrypt the database of the app.

我知道SQLCipher为Android能为我做到这一点。但问题是,我的应用程序已经使用了大量的用户,他们有大量的未加密的数据在里面。

I know about SQLCipher for Android which can do this for me. But the problem is that my app is already used by a lot of users and they have lots of unencrypted data inside it.

现在,我该如何使用SQLCipher与现有的未加密的数据库?所以我所有的previous数据被没有任何问题,新的数据加密的大干快上,因为它应该。

Now, how can I use SQLCipher with an existing unencrypted database? So that all my previous data gets encrypted without any problem and new data gets going as it should.

推荐答案

您可以使用SqlCipher使用下面的命令加密的明文数据库,或者您可以找到关于<一个Java的例子code href="https://github.com/sqlcipher/sqlcipher-android-tests/blob/master/src/main/java/net/zetetic/tests/ImportUnencryptedDatabaseTest.java"相对=nofollow> GitHub的。

You can encrypt a plaintext database using SqlCipher using the following commands or alternatively you can find Java example code on GitHub.

$ ./sqlcipher plaintext.db
sqlite> ATTACH DATABASE 'encrypted.db' AS encrypted KEY 'testkey';
sqlite> SELECT sqlcipher_export('encrypted');
sqlite> DETACH DATABASE encrypted;

您可以在用户的​​数据库进行加密,作为新的应用程序通过重写onUpgrade方法在你的安装程序在安装的一部分。

You can encrypt the user's database as part of the installation of your new app by overriding the onUpgrade method in your installer.

这篇关于加密Android中已有的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆