Android找工作系列之数据安全-ORMLite整合SQLCipher

Android数据库加密,目前就是SQLCipher对SQLite整体加密,微信也是使用这种方式。开源,且支持很多平台。

SQLCipher虽说开源了,但是编译好的jar和so文件,还是要收费的。

但是,我又想用ORMLite这么办?那就把ORMLite和SQLCipher 整合到一起!

1.SQLCipher的集成方式有2种。这里使用的是第二种。

地址:https://www.zetetic.net/sqlcipher/sqlcipher-for-android/

SQLCipher的jar包和so文件下载地址:

http://download.csdn.net/download/feixing345/9760335

2.OrmLite集成方式:

地址:http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_1.html#Getting-Started

下载2个jar导入使用即可。具体如何使用可以参考别人写的博客。

3.OrmLite正式集成SQLCipher

 原理:SQLCipher.JAR包中基本上重写了android.database包中所有的类,全部替换成了net.sqlcipher包。而ormlite-android.jar的数据库操作使用的是android.database。所以只需要把ormlite-android.jar源码下载下来,把数据库操作的方式替换成net.sqlcipher就可以了

3.1 首先在github中下载开源的ormlite-android源码。

下载地址:https://github.com/j256/ormlite-android

将源码copy到Android studio中,需要将ormlite-core.jar下载并导入到工程中。

其次,导入SQLCipher编译好的jar和so文件:

最后,将ormlite-android源码中android.database替换net.sqlcipher即可。

下载地址:

http://download.csdn.net/download/u013914149/10121251

原文地址:https://www.cnblogs.com/hbolin/p/11020016.html