Coder Social home page Coder Social logo

sqlcipherroom's Introduction

SQLCipherRoom

Room作为Android平台的一款对象关系映射框架 并不支持sqlcipher,需要我们使用第三方库来支持 对使用Room生成的数据库加密方法集成方法

 private static SafeHelperFactory factory = new SafeHelperFactory(passphrase);

    public static UserDatabase getINSTANCE(Context context) {
        synchronized (sLock) {
            if (INSTANCE == null) {
                INSTANCE =
                        Room.databaseBuilder(context.getApplicationContext(),
                                UserDatabase.class, DATABASE_NAME)
                                .openHelperFactory(factory)  //encrypt
                                .fallbackToDestructiveMigration()
                                .build();
            }
            return INSTANCE;
        }
    }

下面演示了从/data/data/<package_name>/databases目录下面导出的DB文件通过sqlcipher加密后打开情况

img

也可直接对xxx.db文件直接加密

SQLCipherUtils.getDatabaseState(File);  // 判断文件是否加密 ENCRYPTED, UNENCRYPTED, or DOES_NOT_EXIST

SQLCipherUtils.encrypt(Context, File, char[]); // 加密

sqlcipherroom's People

Contributors

xmaihh avatar

Stargazers

Richard Huang avatar  avatar YuanArcheanNovice avatar wangshenglongrc avatar  avatar / avatar 夜雨Jacky avatar  avatar bailiangjin avatar michaelliu avatar Jokey_Yuan avatar azhansy avatar woshizilong avatar teng.shi avatar

Watchers

James Cloos 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.