今天本想写一片 GAE+goAgent+SwitchySharp 的指南的!但是突然翻出了前段时间写的关于ios中的SQL数据库文件加密的代码,于是乎决定今天就先讲讲这个!~ 那么goAgent将放在周末, 后续的文章中除了文件加密,还有传输数据加密,感兴趣的童鞋 敬请留意。
言归正传,sql的文件加密,我们首先要用到一个库,它就是大名鼎鼎的Sqlcipher, 奉上连接:http://sqlcipher.net,在ios里 我们需要看的文档是这一篇http://sqlcipher.net/ios-tutorial/,文档是全英文的,在此,不详细阐述,只按步骤教大家怎么做,至于为什么做的问题,就需要自己去寻找答案了!
1.下载需要的库 这里我们总共需要3个目录的文件,分别是sqlcipher,openssl-xcode,openssl-1.0.0e。
首先下载第一个
% cd ~/Documents/code//命令行cd到你要下载的目录
% curl -o openssl-1.0.0e.tar.gz http://www.openssl.org/source/openssl-1.0.0e.tar.gz//下载
% tar xzf openssl-1.0.0e.tar.gz //解压缩
附:
SQLCipher uses the widely trusted and peer-reviewed OpenSSL library for all cryptographic functions including the AES-256 algorithm, pseudo random number generation, and PBKDF2 key derivation. OpenSSL isn't framework that is usable directly on the iPhone so we will setup our project to build and link against it as a static library.
Download the 1.0.x stable version from http://www.openssl.org/source/ and extract it to a folder on your system. Since the same OpenSSL source tree may be shared across multiple SQLCipher projects, it's a good idea to place this in some shared location outside of your project folder. Justs make a note of the source directory path for later.
(看不懂英文的童鞋也不用着急,跟着继续做就好了,也很好理解)
OpenSSL是套开源的SSL套件,其函数库是以C語言所写,实现基本的傳輸層資料加密功能。
第二个