Coder Social home page Coder Social logo

react-native-sqlite-storage-sqlcipher's Introduction

react-native-sqlite-storage-sqlcipher

如何在iOS平台下使用react-native-sqlite-storage进行数据库加密的踩坑和问题解决过程

需求:使用react-native-sqlite-storage使用sqlcipher加密组件进行数据库加密

组件介绍

1.react-native-sqlite-storage RN数据库插件,由Cordova的同名插件改造而来
https://github.com/andpor/react-native-sqlite-storage
2.sqlcipher 一款数据库加密工具,不多做评价
https://github.com/sqlcipher/sqlcipher

关于插件使用讨论及踩坑流程

1.andpor/react-native-sqlite-storage#40

原作者好像在插件中留了这个功能,但是用 #ifdef / #endif 屏蔽了,插件的使用说明中并没有留下直接使用的加密功能的使用说明,让我很困扰
2.andpor/react-native-sqlite-storage#217
另外一个小伙问了同样的问题,被建议使用fork的分支
3.https://github.com/dryganets/react-native-sqlite-storage
上述描述的被建议使用的改动分支,iOS分支中被加入了Pods集成的sqlcipher,然后...

exm?pods?自从开始用RN开发都感觉都不认识这个了,嫌麻烦没有使用这种方案(说不定这个会比我接下来使用的简单)
4.https://www.zetetic.net/sqlcipher/ios-tutorial/
当时我就不乐意了,用不了你这个插件我还不能自己写个自定义插件咯?于是,自己按照OC原生开发导入sqlcipher的方式写了个demo,
5.http://blog.csdn.net/u010731949/article/details/78180850?locationnum=5&fps=1
然后按照上述文档在解决了 Implicit declaration of function 'sqlite3_key' is invalid in C99 这个问题
6.发现demo可用而且贼好用,但是要自己封装成RN的自定义组件真的好麻烦啊,所以又看回了react-native-sqlite-storage插件
7.然后玩 塞尔达传说 的时候,(不吹不黑,塞尔达天下无敌,任天堂万物起源)
忽然想到,按写原生sqlcipherDemo的思路集成sqlcipher到插件里面应该可行,
8.于是一顿操作解决问题
将sqlcipher引入项目,放到Library和RN的三方库放一起,参考 https://www.zetetic.net/sqlcipher/ios-tutorial/

去掉 SQLite.xcodeproj/SQLite.m 用 #ifdef / #endif 的屏蔽

顶上加上处理c99问题的代码

demo项目sqlTest已上传
npm install / react-native link 等一顿操作之后,将这里提供的 react-native-sqlite-storage 替换原 node_modules 下的文件 (相对于原版也就加两行代码的事情)
按照文档集成sqlcipher之后即可使用
つづく

react-native-sqlite-storage-sqlcipher's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.