Skip to content
This repository was archived by the owner on Mar 1, 2022. It is now read-only.

Commit 0c351a6

Browse files
committed
Updated read me/changes
1 parent 671bc73 commit 0c351a6

File tree

5 files changed

+108
-25
lines changed

5 files changed

+108
-25
lines changed

README.md

Lines changed: 73 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,103 @@ Secure-preferences
33

44
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-secure--preferences-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/362)
55

6-
This is Android Shared preference wrapper that encrypts the keys and values of Shared Preferences using 256-bit AES. **The key is stored in the perferences and so can be read and extracted by root user.** Keys and values are encrypted and base64 encooded before storing into prefs.
6+
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 HA 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 perferences file and so can be read and extracted by root user.** Recommend use the user password generated option as added in v0.1.0.
77

8-
The sample app is availbile on [playstore](https://play.google.com/store/apps/details?id=com.securepreferences.sample)
8+
The sample app is available on [playstore](https://play.google.com/store/apps/details?id=com.securepreferences.sample)
99

10-
Much of the original code is from Daniel Abraham article on [codeproject](http://www.codeproject.com/Articles/549119/Encryption-Wrapper-for-Android-SharedPreferences). This project was created and shared on Github with his permission.
11-
12-
![screenshot](https://raw.github.com/scottyab/secure-preferences/master/docs/images/ss_frame_secure_pref.png "Sample app Screenshot")
10+
<img src="https://raw.github.com/scottyab/secure-preferences/master/docs/images/ss_frame_secure_pref.png" height="400" alt="Sample app Screenshot" />
1311

1412

13+
##New release v0.1.0
14+
This release is a major refactor of the guts of secure prefs, which is *Not backwards compatible* yet with older versions. So if you have an existing app using this don't upgrade. I'll be looking to add migration into a later release.
15+
16+
#Usage
17+
1518
##Dependency
19+
20+
Maven central is the prefered way:
21+
1622
```java
1723
dependencies {
1824
compile 'com.scottyab:secure-preferences-lib:0.0.4'
1925
}
2026
```
2127

22-
##Release Notes:
23-
0.0.5 (coming soon)
24-
* default AES to CBC mode for increased security
28+
Or clone this repo and add the library as a Android library project/module.
2529

26-
0.0.4
27-
* Gralde support thanks @yelinaung
28-
* Fix for OnPreferenceChanged listener @richardleggett
30+
#Examples
31+
This will use the default shared pref file
2932

30-
0.0.3
33+
```java
34+
SharedPreferences prefs = new SecurePreferences(context);
35+
```
3136

32-
* Added test Project
33-
* Updated sample ready for playstore upload
37+
##Custom pref file
38+
You can define a seperate file for encrpyted preferences.
3439

35-
0.0.2
40+
```java
41+
SharedPreferences prefs = new SecurePreferences(context, null, "my_custom_prefs.xml");
42+
```
43+
44+
45+
##User password
46+
Passing in a password to the SecurePreferences contructor means the key is generated at runtime and *not* stored in the backing pref file.
47+
48+
```java
49+
SharedPreferences prefs = new SecurePreferences(context, "userpassword", "my_user_prefs.xml");
50+
```
3651

37-
* Added methods to get/set strings un-encrypted
38-
* Added backup PBKDF function in case PBKDF2WithHmacSHA1 not supported
39-
* Refactored code to make it easier to change the AES mode and PBKDF function.
40-
* Increased iterations of PBKDF from 1000 to 2000.
52+
##Changing Password
4153

42-
0.0.1
54+
```java
55+
SecurePreferences securePrefs = new SecurePreferences(context, "userpassword", "my_user_prefs.xml");
4356

44-
* Initial import to github I've modified the project structure.
45-
* Included the Android base64 class so library can be used by Android 2.1+.
46-
* Enhanced the sample project dumps current prefs to illustrate the fact they are stored encrypted and Base64 encoded.
57+
58+
```
59+
60+
61+
#What does the data look like?
62+
63+
SharedPreferences keys and values are stored as simple map in an XML file.
64+
65+
##XML using Standard Android SharedPreferences
66+
67+
68+
```xml
69+
<map>
70+
<int name="timeout" value="500" />
71+
<boolean name="is_logged_in" value="true" />
72+
</map>
73+
```
74+
75+
##XML with SecurePreferences
76+
77+
78+
```xml
79+
<map>
80+
<string name="TuwbBU0IrAyL9znGBJ87uEi7pW0FwYwX8SZiiKnD2VZ7">
81+
pD2UhS2K2MNjWm8KzpFrag==:MWm7NgaEhvaxAvA9wASUl0HUHCVBWkn3c2T1WoSAE/g=rroijgeWEGRDFSS/hg
82+
</string>
83+
<string name="8lqCQqn73Uo84Rj">k73tlfVNYsPshll19ztma7U">
84+
pD2UhS2K2MNjWm8KzpFrag==:MWm7NgaEhvaxAvA9wASUl0HUHCVBWkn3c2T1WoSAE/g=:jWm8KzUl0HUHCVBWkn3c2T1WoSAE/g=
85+
</string>
86+
</map>
87+
```
4788

4889

4990
###Disclaimer
50-
It's not bullet proof security (in fact it's more like obfuscation of the perferences) but it's a quick win for incrementally making your android app more secure. For instance it'll stop users on rooted devices easily modifiying your app's shared prefs.
91+
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 modifiying your app's shared prefs.
92+
*Recommend using the user password based prefs as introducted in v0.1.0.*
5193

5294

5395
###Contributing
54-
Please do send me pull requests, but also bugs and enhancement requests are welcome. Although no guarantees on when I can review them.
96+
Please do send me pull requests, but also bugs, issues and enhancement requests are welcome please add an issue.
5597

5698

5799
###Licence
100+
101+
Much of the original code is from Daniel Abraham article on [codeproject](http://www.codeproject.com/Articles/549119/Encryption-Wrapper-for-Android-SharedPreferences). This project was created and shared on Github with his permission.
102+
58103
Apache License, Version 2.0
59104

60105

@@ -72,3 +117,6 @@ Apache License, Version 2.0
72117
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
73118
See the License for the specific language governing permissions and
74119
limitations under the License.
120+
121+
122+
Lock icon for sample app licenced under creativecommons created by Sam Smith via [thenounproject.com](http://thenounproject.com/term/lock/5704/)

changes.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
##Release Notes:
2+
0.1.0
3+
This release is a major refactor of the guts of secure prefs, which is *Not backwards compatible* yet with older versions. So if you have an existing app using this don't upgrade. I'll be looking to add migration into a later release.
4+
5+
* uses a new and stronger [Crypto library](https://github.com/scottyab/java-aes-crypto) under the hood
6+
* includes PRNG fixes that effects JellyBean devices as per [google dev blog article](http://android-developers.blogspot.nl/2013/08/some-securerandom-thoughts.html)
7+
* supports password based key generation so the key is not persisted
8+
* change password supported
9+
* updated sample app
10+
* removed test project and added tests as part of main project
11+
* refactored library project to standard gradle structure
12+
* published to maven central
13+
14+
15+
0.0.4
16+
* Gralde support thanks @yelinaung
17+
* Fix for OnPreferenceChanged listener @richardleggett
18+
19+
0.0.3
20+
21+
* Added test Project
22+
* Updated sample ready for playstore upload
23+
24+
0.0.2
25+
26+
* Added methods to get/set strings un-encrypted
27+
* Added backup PBKDF function in case PBKDF2WithHmacSHA1 not supported
28+
* Refactored code to make it easier to change the AES mode and PBKDF function.
29+
* Increased iterations of PBKDF from 1000 to 2000.
30+
31+
0.0.1
32+
33+
* Initial import to github I've modified the project structure.
34+
* Included the Android base64 class so library can be used by Android 2.1+.
35+
* Enhanced the sample project dumps current prefs to illustrate the fact they are stored encrypted and Base64 encoded.
85.7 KB
Loading
10 KB
Loading
4.02 KB
Loading

0 commit comments

Comments
 (0)