All Projects → scottyab → Secure Preferences

scottyab / Secure Preferences

Android Shared preference wrapper than encrypts the values of Shared Preferences. It's not bullet proof security but rather a quick win for incrementally making your android app more secure.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Secure Preferences

Materialpreferences
A highly flexible set of lovely looking views that provides functionality of preferences.
Stars: ✭ 495 (-67.58%)
Mutual labels:  sharedpreferences
Android Debug Database
A library for debugging android databases and shared preferences - Make Debugging Great Again
Stars: ✭ 7,946 (+420.37%)
Mutual labels:  sharedpreferences
Sharedchamber
Android Secure SharedPreferences Using Facebook Conceal Encryption
Stars: ✭ 96 (-93.71%)
Mutual labels:  sharedpreferences
Kotpref
Kotpref - Android SharedPreferences delegation library for Kotlin
Stars: ✭ 618 (-59.53%)
Mutual labels:  sharedpreferences
Mlcache
A library make cache easily
Stars: ✭ 9 (-99.41%)
Mutual labels:  sharedpreferences
Easysp
A SharedPreferences wrapper that has a fluent interface to store data
Stars: ✭ 75 (-95.09%)
Mutual labels:  sharedpreferences
Colorpickerpreference
🎨 A library that lets you implement ColorPicker, ColorPickerDialog, ColorPickerPreference.
Stars: ✭ 407 (-73.35%)
Mutual labels:  sharedpreferences
React Native Encrypted Storage
React Native wrapper around SharedPreferences and Keychain to provide a secure alternative to Async Storage
Stars: ✭ 110 (-92.8%)
Mutual labels:  sharedpreferences
Easypreferences
This class simplifies calls to SharedPreferences in a line of code. It can also do more like: saving a list of strings, integers and saving images. All in 1 line of code!
Stars: ✭ 34 (-97.77%)
Mutual labels:  sharedpreferences
Xpref
A SharedPreferences' wrapper that truly supported sharing data across multi-process
Stars: ✭ 80 (-94.76%)
Mutual labels:  sharedpreferences
Shpref Library
💾 Android Kotlin library. Shared preferences wrapper. (2020)
Stars: ✭ 16 (-98.95%)
Mutual labels:  sharedpreferences
Harmony
Multi-process SharedPreference implementation without ContentProvider
Stars: ✭ 27 (-98.23%)
Mutual labels:  sharedpreferences
Secure Pref Manager
Secure Preference Manager for android. It uses various Encryption to protect your application's Shared Preferences.
Stars: ✭ 75 (-95.09%)
Mutual labels:  sharedpreferences
Secured Preference Store
A cryptography library and a SharedPreferences wrapper for Android that encrypts the content with 256 bit AES encryption. The Encryption key is securely stored in device's KeyStore.
Stars: ✭ 562 (-63.2%)
Mutual labels:  sharedpreferences
Contacts
A flutter project with Implementation of a Contacts app in 4 ways (API, Custom, Preferences and Sqflite).
Stars: ✭ 100 (-93.45%)
Mutual labels:  sharedpreferences
Binaryprefs
Rapidly fast and lightweight re-implementation of SharedPreferences which stores each preference in files separately, performs disk operations via NIO with memory mapped byte buffers and works IPC (between processes). Written from scratch.
Stars: ✭ 484 (-68.3%)
Mutual labels:  sharedpreferences
Easyandroid
一系列简单、轻量、方便的Android开发工具集合(持续更新中),包括Android动态权限、SharedPreferences、反射、日志、Toast、Bundle、MVP、线程池、Html、图文混排、蒙层引导、拍照、图库选择等
Stars: ✭ 1,039 (-31.96%)
Mutual labels:  sharedpreferences
Movieapp
🎬 MovieApp is a Flutter application built to demonstrate the use of modern development tools with best practices implementation like Modularization, BLoC, Dependency Injection, Dynamic Theme, Cache, Shimmer, Testing, Flavor, CI/CD, etc.
Stars: ✭ 117 (-92.34%)
Mutual labels:  sharedpreferences
Kripton
A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Stars: ✭ 110 (-92.8%)
Mutual labels:  sharedpreferences
Multiplatform Preferences
Kotlin Multi Platform Preferences, for android an ios : SharedPreferences & NSUserDefault
Stars: ✭ 76 (-95.02%)
Mutual labels:  sharedpreferences

Secure-preferences - Deprecated

  • Please use EncryptedSharedPreferences from androidx.security in preferenced to secure-preference. (There are no active maintainers Secure-preferences)

This is Android Shared preference wrapper that encrypts the values of Shared Preferences using AES 128, CBC, and PKCS5 padding with integrity checking in the form of a SHA 256 hash. Each key is stored as a one way SHA 256 hash. Both keys and values are base64 encoded before storing into prefs xml file. By default the generated key is stored in the backing preferences file and so can be read and extracted by root user. Recommend use the user password generated option as added in v0.1.0.

The sample app is available on playstore

Sample app Screenshot

Release v0.1.0+

The v0.1.0 release was a major refactor of the guts of secure prefs, which is Not backwards compatible yet with older 0.0.1 - 0.0.4 versions. So if you have an existing app using this don't upgrade. I'll be looking to add migration into a later release.

Full list of changes

Usage

Dependency

Maven central is the preferred way:

Note: v0.1.0 was dependent on snapshot of aes-crypto, this is only as I was waiting for the aes-crypto repo owner to upload to maven. I've sorted this for v0.1.1+ which is no longer dependent on Snapshot repo.

dependencies {
    implementation 'com.scottyab:secure-preferences-lib:0.1.7'
}

Download

Or download the release .aar or clone this repo and add the library as a Android library project/module.

ProGuard config

As of v0.1.4 no specific -keep config is needed.

DexGuard

There is specific DexGuard config supplied with DexGuard 7+ located <dexgaurd root>/samples/advanced/SecurePreferences

Examples

This will use the default shared pref file

SharedPreferences prefs = new SecurePreferences(context);     

Custom pref file

You can define a separate file for encrypted preferences.

SharedPreferences prefs = new SecurePreferences(context, null, "my_custom_prefs.xml");

User password - (recommended)

Using a password that the user types in that isn't stored elsewhere in the app passed to the SecurePreferences constructor means the key is generated at runtime and not stored in the backing pref file.

SharedPreferences prefs = new SecurePreferences(context, "userpassword", "my_user_prefs.xml");

Changing Password

SecurePreferences securePrefs = new SecurePreferences(context, "userpassword", "my_user_prefs.xml");
securePrefs.handlePasswordChange("newPassword", context);

What does the data look like?

SharedPreferences keys and values are stored as simple map in an XML file. You could also use a rooted device and an app like cheatdroid

XML using Standard Android SharedPreferences

<map>
    <int name="timeout" value="500" />
    <boolean name="is_logged_in" value="true" />
</map>

XML with SecurePreferences

<map>
    <string name="TuwbBU0IrAyL9znGBJ87uEi7pW0FwYwX8SZiiKnD2VZ7">
        pD2UhS2K2MNjWm8KzpFrag==:MWm7NgaEhvaxAvA9wASUl0HUHCVBWkn3c2T1WoSAE/g=rroijgeWEGRDFSS/hg
    </string>
    <string name="8lqCQqn73Uo84Rj">k73tlfVNYsPshll19ztma7U">
        pD2UhS2K2MNjWm8KzpFrag==:MWm7NgaEhvaxAvA9wASUl0HUHCVBWkn3c2T1WoSAE/g=:jWm8KzUl0HUHCVBWkn3c2T1WoSAE/g=
    </string>
</map>

Disclaimer

By default it's not bullet proof security (in fact it's more like obfuscation of the preferences) but it's a quick win for incrementally making your android app more secure. For instance it'll stop users on rooted devices easily modifying your app's shared prefs. Recommend using the user password based prefs as introduced in v0.1.0.

Contributing

Please do send me pull requests, but also bugs, issues and enhancement requests are welcome please add an issue.

Licence

Much of the original code is from Daniel Abraham article on codeproject. This project was created and shared on Github with his permission.

Apache License, Version 2.0

Copyright (C) 2013, Daniel Abraham, Scott Alexander-Bown

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.

The sample app Lock icon for sample app licenced under Creative Commons created by Sam Smith via thenounproject.com

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].