Giter Site home page Giter Site logo

ranjan101 / secure-pref-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from prashantsolanki3/secure-pref-manager

0.0 2.0 0.0 207 KB

Secure Preference Manager for android. It uses various Encryption to protect your application's Shared Preferences.

Home Page: https://prashantsolanki3.github.io/Secure-Pref-Manager/

License: Apache License 2.0

Java 100.00%

secure-pref-manager's Introduction

Secure-Pref-Manager

Android Arsenal Travis CI ##Secure Preference Manager is a simple Library to help you protect your Shared Preferences. Secure Preference Manager for android. It uses various encryption techniques to protect your application's Shared Preferences.

##Setup Add jitpack to your project’s repositories.

repositories {
        // ...
        maven { url "https://jitpack.io" }
    }

Then add Secure-Pref-Manager to your Module’s dependencies

dependencies {
	        compile 'com.github.prashantsolanki3:Secure-Pref-Manager:0.25'
	}

##Usage

###Initialize SecurePrefManager anywhere before using it.

  • Basic Initialization
       new SecurePrefManagerInit.Initializer(getApplicationContext())
               .initialize();
  • Recommended Initialization
  • AES Encryption by Default.
  • Auto Generated Key.
       new SecurePrefManagerInit.Initializer(getApplicationContext())
               .useEncryption(true)
               .initialize();
  • Advance Initialization: Only if you wanna add Custom Encryption Methods.
       new SecurePrefManagerInit.Initializer(getApplicationContext())
               .useEncryption(true)
               .setCustomEncryption(new Encryptor(getApplicationContext()) {
                   @Override
                   public String encrypt(String s) throws Exception {
                       // Your Encryption Algorithm
                       return encryptedString;
                   }

                   @Override
                   public String decrypt(String s) throws Exception {
                       // Your Decryption Algorithm
                       return decryptedString;
                   }
               })
               .initialize();

Adding and Retrieving Preferences

  • Adding
        SecurePrefManager.with(this)
                .set("user_name")
                .value("LoremIpsum")
                .go();
  • Retrieving
        String userName = SecurePrefManager.with(this)
                .get("user_name")
                .defaultValue("unknown")
                .go();

Hide Preferences from 3rd Party applications (EXPERIMENTAL)

  • Unhide Preferences when the activity starts
@Override
    protected void onStart() {
        super.onStart();
        SecurePrefManager.with(getApplicationContext())
                .unhide(new HidePreferences.PreferenceUpdateListener() {
                    @Override
                    public void onFailure() {
                        Log.d("unhiding", "Failed");
                    }

                    @Override
                    public void onProgress(int p, int max) {
                        Log.d("unhiding", "Progress: " + p + "/" + max);
                    }

                    @Override
                    public void onSuccess() {
                        Log.d("unhiding", "Success");
                    }
                });
    }
  • Hide preferences when leaving the activity
@Override
    protected void onPause() {
        SecurePrefManager.with(getApplicationContext())
                .hide(new HidePreferences.PreferenceUpdateListener() {
                    @Override
                    public void onFailure() {

                    }

                    @Override
                    public void onProgress(int p, int max) {

                    }

                    @Override
                    public void onSuccess() {

                    }
                });
    }

Have Fun!

secure-pref-manager's People

Contributors

prashantsolanki3 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.