GithubHelp home page GithubHelp logo

tthana / sqlitere Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mobi-life/sqlitere

0.0 2.0 0.0 3.11 MB

Customized version of Sqlite library supporting REGEXP and Encryption for Android

Java 4.18% HTML 0.02% C 94.41% Makefile 0.04% C++ 1.35%

sqlitere's Introduction

SqliteRE (Regex-Encryption)

Customized version of Sqlite library supporting REGEXP and Encryption for Android. This project is a mix/merge of three other projects that are listed below.

How to build the native library

  • Point to the directory src/main/
  • Run the ndk-build in the command prompt
  • move compiled native library from libs to jniLibs

How to use

Building this library project using gradle in command line or from Android Studio will produce .aar file , copy the sqlite.aar file to the libs directory of your own project, then add the line below to the dependencies section in the build.gradle :

compile ('com.mobilife.sqlitere:sqlitere@aar')

Now you just need to change import part of your code to import com.mobilife.sqlitere.database.sqlite.SQLiteDatabase; and anything else will remain exactly how you use normal android sqlite classes.

Regular Experssion Compare

you can use REGEXP operator to compare a field with a regex string

SELECT FirstName FROM Persons WHERE LastName REGEXP '^abc'

Encryption

PRAGMA key

  • example usage: PRAGMA key='passphrase';
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
db.execSQL("PRAGMA key = 'passphrase'");

PRAGMA rekey

  • example usage: PRAGMA rekey='passphrase';
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
db.execSQL("PRAGMA key = 'current passphrase'");
db.execSQL("PRAGMA rekey = 'new passphrase'");
  • example of decrypting: PRAGMA rekey='';
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
db.execSQL("PRAGMA key = 'current passphrase'");
db.execSQL("PRAGMA rekey = ''");

Encrypting a new db - order

open          // <-- db is still plain text
key           // <-- db is now fully encrypted
use as usual

Opening an encrypted DB - order

open          // <-- db is fully encrypted
key           // <-- db is still fully encrypted
use as usual  // <-- read/written pages are fully encrypted and only decrypted in-memory

Changing the key - order

open          // <-- db is fully encrypted
key           // <-- db is still fully encrypted
rekey         // <-- db is still fully encrypted
use as usual  

Decrypting - order

open              // <-- db is fully encrypted
key               // <-- db is still fully encrypted
rekey with null   // <-- db is now fully decrypted to plain text
use as usual

References

-Android native and java helper classes :

https://sqlite.org/android/doc/trunk/www/index.wiki

-Encryption Module :

https://github.com/rindeal/SQLite3-Encryption

-Regexp Module :

https://github.com/litehelpers/Android-sqlite-native-driver-regexp-pcre

-This project uses sqlite amalgamation v3.12.2 , you can replace it with the lastest version from here :

https://github.com/liteglue/sqlite-amalgamation

sqlitere's People

Contributors

mobi-life 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.