Secure Preferences

Additional

Language
Java
Version
N/A
Created
Mar 3, 2017
Updated
Oct 18, 2017
Owner
Hussain Al-Derry (HussainDerry)
Contributor
Hussain Al-Derry (HussainDerry)
1
Activity
Badge
Generate
Download
Source code

Show card

Secure Preferences

A simple library that provides an AES encrypted version of the Android shared preferences

Setup

Gradle

compile 'com.github.hussainderry:secure-preferences:2.1.0'

Sample Usage

Configuring Encryption Parameters

// Minimum Configurations
SecurityConfig minimumConfig = new SecurityConfig.Builder(PASSWORD)
        .build();

// Full Configurations
SecurityConfig fullConfig = new SecurityConfig.Builder(PASSWORD)
        .setAesKeySize(256) // key size in bits
        .setPbkdf2SaltSize(32) // salt size in bytes
        .setPbkdf2Iterations(24000)
        .setDigestType(DigestType.SHA256)
        .build();

SecurePreferences mPreferences = SecurePreferences.getInstance(MainActivity.this, FILENAME, minimumConfig);
SecurePreferences.Editor mEditor = mPreferences.edit();

Getting Data Asynchronously

AsyncDataLoader mAsyncLoader = mPreferences.getAsyncDataLoader();
Future<String> mFuture = mAsyncLoader.getString("name", "default");

/* Do something while the data is being fetched */

if(mFuture.isDone()){
    String data = mFuture.get();
}

Developed By

  • Hussain Al-Derry

    Email - hussain.derry@gmail.com

License

Copyright 2017 Hussain Al-Derry

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.