├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── pddstudio │ │ │ └── encryptedpreferences │ │ │ ├── MockUtils.java │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── pddstudio │ │ │ └── encryptedpreferences │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── pddstudio │ │ └── encryptedpreferences │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── encrypted-preferences ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ └── values │ │ │ │ ├── config.xml │ │ │ │ └── about_strings.xml │ │ └── java │ │ │ └── com │ │ │ └── pddstudio │ │ │ └── preferences │ │ │ └── encrypted │ │ │ └── EncryptedPreferences.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── pddstudio │ │ │ └── preferences │ │ │ └── encrypted │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── pddstudio │ │ └── preferences │ │ └── encrypted │ │ ├── ApplicationTest.java │ │ ├── SingletonCreationTest.java │ │ ├── UtilsTest.java │ │ ├── EncryptedEditorTest.java │ │ └── EncryptedPreferencesTest.java ├── proguard-rules.pro ├── gradle.properties ├── build.gradle └── maven-push.gradle ├── settings.gradle ├── .idea ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── modules.xml ├── runConfigurations.xml ├── gradle.xml ├── compiler.xml └── misc.xml ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── TODO.md ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew └── README.md /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /encrypted-preferences/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':encrypted-preferences' 2 | -------------------------------------------------------------------------------- /encrypted-preferences/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/EncryptedPreferences/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/EncryptedPreferences/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/EncryptedPreferences/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/EncryptedPreferences/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/EncryptedPreferences/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PDDStudio/EncryptedPreferences/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /encrypted-preferences/src/main/res/values/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | ##To-Do List for everything regarding EncryptedPreferences 2 | 3 | ###ToDo Library Module 4 | 5 | - Allow [password change during runtime](https://github.com/PDDStudio/EncryptedPreferences/issues/5) (with automated migration of previous saved data) 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 11 11:06:39 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EncryptedPreferences 3 | Add random value 4 | Register Preference Listener 5 | Unregister Preference Listener 6 | Import Mocked Preferences 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/pddstudio/encryptedpreferences/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.encryptedpreferences; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /encrypted-preferences/src/test/java/com/pddstudio/preferences/encrypted/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.preferences.encrypted; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/pddstudio/encryptedpreferences/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.encryptedpreferences; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /encrypted-preferences/src/androidTest/java/com/pddstudio/preferences/encrypted/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.preferences.encrypted; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/pddstudio/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /encrypted-preferences/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/pddstudio/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /encrypted-preferences/gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2015 - Patrick J - earthview-android 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | POM_NAME=EncryptedPreferences 18 | POM_ARTIFACT_ID=encrypted-preferences 19 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion '25.0.2' 6 | 7 | defaultConfig { 8 | applicationId "com.pddstudio.encryptedpreferences" 9 | minSdkVersion 16 10 | targetSdkVersion 25 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:24.2.0' 26 | compile project(':encrypted-preferences') 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Base .gitignore taken from "https://raw.githubusercontent.com/github/gitignore/master/Android.gitignore" 2 | # Built application files 3 | *.apk 4 | *.ap_ 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | 17 | # Gradle files 18 | .gradle/ 19 | build/ 20 | 21 | # Local configuration file (sdk path, etc) 22 | local.properties 23 | 24 | # Proguard folder generated by Eclipse 25 | proguard/ 26 | 27 | # Log Files 28 | *.log 29 | 30 | # Android Studio Navigation editor temp files 31 | .navigation/ 32 | 33 | # Android Studio captures folder 34 | captures/ 35 | 36 | # Intellij 37 | *.iml 38 | .idea/workspace.xml 39 | .idea/tasks.xml 40 | .idea/libraries 41 | .idea/ 42 | 43 | # Keystore files 44 | *.jks 45 | 46 | # External native build folder generated in Android Studio 2.2 and later 47 | .externalNativeBuild 48 | .idea/vcs.xml 49 | .idea/misc.xml 50 | .idea/instapk.xml 51 | instapk.log* -------------------------------------------------------------------------------- /encrypted-preferences/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply from: 'maven-push.gradle' 3 | 4 | android { 5 | compileSdkVersion 25 6 | buildToolsVersion '25.0.2' 7 | 8 | defaultConfig { 9 | minSdkVersion 10 10 | targetSdkVersion 25 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | versionCode 5 13 | versionName "1.3.0" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | 26 | testCompile 'junit:junit:4.12' 27 | androidTestCompile 'junit:junit:4.12' 28 | androidTestCompile 'com.android.support.test:runner:0.5' 29 | androidTestCompile 'com.android.support.test:rules:0.5' 30 | androidTestCompile 'com.squareup.assertj:assertj-android:1.1.1' 31 | 32 | compile 'com.scottyab:aescrypt:0.0.1' 33 | } 34 | -------------------------------------------------------------------------------- /encrypted-preferences/src/main/res/values/about_strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Patrick J 6 | http://pddstudio.com/ 7 | EncryptedPreferences 8 | An Android Library to securely read and write encrypted values to your SharedPreferences. 9 | 1.2.0 10 | https://github.com/PDDStudio/EncryptedPreferences 11 | apache_2_0 12 | true 13 | https://github.com/PDDStudio/EncryptedPreferences 14 | -------------------------------------------------------------------------------- /encrypted-preferences/src/androidTest/java/com/pddstudio/preferences/encrypted/SingletonCreationTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.preferences.encrypted; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.assertNotNull; 12 | 13 | /** 14 | * Created by pddstudio on 11/09/16. 15 | */ 16 | @RunWith(AndroidJUnit4.class) 17 | public class SingletonCreationTest { 18 | 19 | Context context; 20 | EncryptedPreferences encryptedPreferences; 21 | 22 | @Before 23 | public void setup() { 24 | context = InstrumentationRegistry.getContext(); 25 | encryptedPreferences = new EncryptedPreferences.Builder(context).withEncryptionPassword("test").withSaveAsSingleton(true).build(); 26 | } 27 | 28 | @Test 29 | public void testSingletonInstanceExists() { 30 | EncryptedPreferences encryptedPreferences = EncryptedPreferences.getSingletonInstance(); 31 | assertNotNull(encryptedPreferences); 32 | } 33 | 34 | @Test(expected = RuntimeException.class) 35 | public void testSingletonInstanceException() { 36 | encryptedPreferences = new EncryptedPreferences.Builder(context).withEncryptionPassword("test").build(); 37 | EncryptedPreferences.getSingletonInstance(); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /encrypted-preferences/src/androidTest/java/com/pddstudio/preferences/encrypted/UtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.pddstudio.preferences.encrypted; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Before; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.assertEquals; 12 | 13 | /** 14 | * Created by pddstudio on 13/09/16. 15 | */ 16 | @RunWith(AndroidJUnit4.class) 17 | public class UtilsTest { 18 | 19 | private static final String VALUE_ENCRYPTED = "2x0P1XxQx0P1XxmRkVOU5DIM1XLHI77PM7eIPXPn4wHzvdmTeIzD8x0P3Xx"; 20 | private static final String VALUE_UNENCRYPTED = "This is an unencrypted message!"; 21 | 22 | Context context; 23 | EncryptedPreferences encryptedPreferences; 24 | 25 | @Before 26 | public void setup() { 27 | context = InstrumentationRegistry.getContext(); 28 | encryptedPreferences = new EncryptedPreferences.Builder(context).withEncryptionPassword("test").withPreferenceName(getClass().getSimpleName()).build(); 29 | } 30 | 31 | @Test 32 | public void testStringEncryption() { 33 | String encrypted = encryptedPreferences.getUtils().encryptStringValue(VALUE_UNENCRYPTED); 34 | assertEquals(VALUE_ENCRYPTED, encrypted); 35 | } 36 | 37 | @Test 38 | public void testStringDecryption() { 39 | String decrypted = encryptedPreferences.getUtils().decryptStringValue(VALUE_ENCRYPTED); 40 | assertEquals(VALUE_UNENCRYPTED, decrypted); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 |