Giter Club home page Giter Club logo

sqlcipher's Introduction

sqlcipher

sqlcipher 是一个基于openssl加密功能sqlite3。形式上增加一些与加密功能相关sql语句;本质上是一个经过重新编译的sqlite3,不破坏原有功能,仅仅增添了加密特性。

简介

SQLCipher是开源SQLite的一个扩展,此处不是作为SQLite插件,而是指扩展其功能,扩展sqlite API,因为SQLCipher需要重新编译SQLite,最终生成一个集成加密功能的node_sqlit3.nodenode文件。SQLCipher对整个数据库文件加密。SQLCipher安装不需要复杂的配置环境,一般系统有npm就可以针对一些环境进行安装,在过程中会自动安装构建的依赖项。与加密功能的sql语句往往放置最前面,一般是连接数据库之后,就执行这些语句。

支持平台

  • C/C++
  • Obj-C
  • QT
  • Win32/.NET
  • Java
  • Python
  • Ruby
  • Linux
  • Mac OS X
  • iPhone/IOS
  • Android
  • Xamarin.IOS
  • Xamarin.Android
  • Electron

用法

var SQLite3 = require('sqlcipher').verbose();
var sqlite = new SQLite3.Database('./test-win.db');

sqlite.run("pragma key = 'secret'");
sqlite.run("pragma cipher = 'aes-256-cbc'");//optional, default cipher be eqaul to 'aes-256-cbc'

注意:sqlcipher该插件是在sqlite3的基础上增添了加密功能。因此,使用sqlcipher可以对数据库文件进行加密或不加密。如果要对数据库文件进行加密,则连接(创建)数据库文件后,第一条sql语句必须是pragma key = '...',否则将会出现意想不到的错误。

安装

npm install sqlcipher 

通过运行以上命令,将会根据系统的环境编译出相应(系统下node版本以及node位数)的sqlciher。默认支持以下三种系统环境。

  • windows
  • mac
  • linux

通过携带参数可以在指定环境下进行编译。特定环境安装

npm install sqlcipher --target=`目标运行环境版本号` --target_arch=`目标运行环境位数` --dist-url=`目标运行环境下载地址` --runtime=`目标运行环境`

加密算法

sqlcipher基于openssl加密库,支持多种加密算法,在实际开发中可以使用默认算法aes-256-cbc或者在支持的加密算法中选择其中某一个。

  • aes-128-cbc
  • aes-192-cfb
  • aes-256-cbc(默认)
  • cast
  • rc4

API

sqlcipher 常用api有指定加密秘钥、指定加密算法、更换秘钥等。当然,如果需要改善加密环境下的sqlite性能,有更详细的api(即sql语句)去优化项目。

1.加密秘钥

pragma key = 'secret';

2.加密算法

pragma cipher = 'aes-128-cbc';

3.更换秘钥

pragma rekey = 'aes-128-cbc';

sqlcipher's People

Contributors

zhouchangsheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sqlcipher's Issues

Failed to find module: "sqlcipher"

I tried to integrate this module with Nativescript with angular framework's app.

But after import, I got followed error.

Failed to find module: "sqlcipher" , relative to : app/tns_modules/
FYI,
screenshot_2017-08-14-15-48-54 1

Thanks.

The specified module could not be found.

Uncaught Error: The specified module could not be found.
\?\F:\project_name\node_modules\sqlcipher\node_modules\sqlite3\lib\binding\electron-v1.7-win32-x64\node_sqlite3.node
您好!请问这个问题是由于什么原因引起的

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.