Skip to content

Commit 1e07dd1

Browse files
Update README.md
1 parent 0e769f4 commit 1e07dd1

File tree

1 file changed

+91
-2
lines changed

1 file changed

+91
-2
lines changed

README.md

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,91 @@
1-
# Android Development Helper
2-
1+
<h1 align="center">Securing Android App with Encrypted SharedPreferences</h1>
2+
3+
<p align="center">
4+
<a href="https://play.google.com/store/apps/details?id=com.sumino.issave.storysaver.photovideo.downloader">
5+
<img src="https://miro.medium.com/v2/resize:fit:828/format:webp/1*pA-q5kPuCdZ1VzLAyXxFBg.jpeg" width="1280" />
6+
</a>
7+
</p>
8+
9+
10+
<div align="center">
11+
<a href="https://t.me/banrossyn" target="_blank"><img src="https://img.shields.io/badge/Telegram-26A5E4.svg?logo=Telegram&logoColor=white"></a>
12+
<a href="https://wa.me/+919694260426/" target="_blank"><img src="https://img.shields.io/badge/WhatsApp-25D366.svg?logo=WhatsApp&logoColor=white"></a>
13+
<a href="https://www.linkedin.com/in/banrossyn/" target="_blank"><img src="https://img.shields.io/badge/LinkedIn-0A66C2.svg?logo=LinkedIn&logoColor=white"></a>
14+
<a href="mailto:banrossyn@gmail.com"><img src="https://img.shields.io/badge/Gmail-EA4335.svg?logo=Gmail&logoColor=white"></a>
15+
<a href=https://www.instagram.com/androidwithrossyn/><img alt="insta" src="https://img.shields.io/badge/Instagram-E4405F.svg?logo=Instagram&logoColor=white"></a>
16+
<a href="https://medium.com/@banrossyn/securing-android-app-with-encrypted-sharedpreferences-8a5e98783485"><img alt="" src="https://img.shields.io/badge/Medium-000000.svg?logo=Medium&logoColor=white"></a>
17+
</div>
18+
19+
### Generally data is saved in this way in Android devices.
20+
21+
```xml
22+
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
23+
<map>
24+
<boolean name="googleMapShow" value="true" />
25+
<int name="dateFormat" value="7" />
26+
<boolean name="isShowTemperature" value="true" />
27+
<boolean name="isShowLevelIndicator" value="false" />
28+
<string name="language">en</string>
29+
<int name="latLongFormat" value="2" />
30+
<boolean name="isShowDate" value="true" />
31+
<int name="selectedTemplate" value="0" />
32+
<boolean name="isShowShortAddress" value="true" />
33+
<boolean name="firstTime" value="false" />
34+
<boolean name="isShowLongAddress" value="true" />
35+
<boolean name="isShowLatLong" value="true" />
36+
<boolean name="isShowTime" value="true" />
37+
<int name="temperatureFormat" value="1" />
38+
<int name="timeFormat" value="8" />
39+
<int name="googleMapType" value="1" />
40+
</map>
41+
```
42+
43+
### But when we use Encrypted SharedPreferences.
44+
```xml
45+
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
46+
<map>
47+
<string name="__androidx_security_crypto_encrypted_prefs_key_keyset__">12a901bc682e67316d97810d5c4ed741daaeddd8877e30137e1b60d4094b04a6ff0bd27c351334ece9568e0b6a3d4b0de494c5577cd71a614e4198c02b8ce62626579ff52740fb41336fe4b012861f5b0533668d2642db6c45025f4428cf6fcd1aba151e991a4e1785dbd0848c8ded29a7540ad8a31236fd40b8c4ec9fa08b5ddf07ed49d6ffb42dbfa98c1a9a06c929f46120bcc6c563e82714e2f4134915b989ed0e75036428bcec24d37d1a4408d2a9e1c304123c0a30747970652e676f6f676c65617069732e636f6d2f676f6f676c652e63727970746f2e74696e6b2e4165735369764b6579100118d2a9e1c3042001</string>
48+
<string name="AUh4VNJxfVMtKEShUAH66Y/Wd6tacepdmB51suathcQ+YCrsu4hZ0Xg=">ARpRaxiHZmU9NmpOYhXGsKFWh0Q5gfG1YtjOZ+/ET0vY/zU4Pe4=</string>
49+
<string name="AUh4VNJW7atm/QULrLCmY/d2aNzirJKQGNOA3WOPUb0=">ARpRaxipyG/6dldVpNFeXh4JEO+NjL6JxmH24TTQVBj1xDVt4YKpEK8=</string>
50+
<string name="AUh4VNJyHr2mLKGjNgD1KKyjYWNeUMCaUEwd9BTrIk/ycU9l">ARpRaxhaVtgbMw1OzeIB/+3Nywr2+DM4pzP8S9M3Jd0Qd3bvKtQXBN4=</string>
51+
<string name="__androidx_security_crypto_encrypted_prefs_value_keyset__">128801cb3c76b722706eeed2f367d681c440c160a4cad6d6279d87eb1ae86494ac213f596c289d9b677f1aff5d6152fbf777fe5e57319363213e1ad6dea868e104cc6c3772924516f3e6026e863dcf3a29547876e83c833e6d7a711c86fec53a9445c09bfbe47fb3bf3d3b5339ef9c80da7a7198a6c9a2736e9a55f2039a455ddaf7fce792200904df97921a440898d6c5d201123c0a30747970652e676f6f676c65617069732e636f6d2f676f6f676c652e63727970746f2e74696e6b2e41657347636d4b657910011898d6c5d2012001</string>
52+
<string name="AUh4VNLEMzO0ZEzywCdpX5nBzKTXdomqrA86p2Qz1hNg3DniJQw=">ARpRaxi7ULeVm2XWXKuSkU/0EzQKvdlou87SmUcBW4iaZMRvBgk=</string>
53+
<string name="AUh4VNLBzx1AEDT0DKye1uJvGOy0pDUu/+5L4EVNp6VeMFd7Ua8=">ARpRaxg8hP0mELpEOwh0nfVD6wd1K8FEt78EjzdWESkBk+nY0hE=</string>
54+
<string name="AUh4VNKRI5oaAyh3ukO1nrUvZOyznA8Wq1PUU0kZ1g==">ARpRaxi3ROeOi0fEMQ4i4Px+1ryY+adkx7aG5zBBWwD+9hPfv20=</string>
55+
<string name="AUh4VNJG2G6tiib4AgyC1Zyp+JB0fwinTJRyTkvooQ==">ARpRaxgClZXUx9+dAt8DPN/pWap8QTWm5cGiIMwB0OHDNPZJs2gMu60=</string>
56+
<string name="AUh4VNL4/Rv9MNzDJTM5VPM9seA71pP1sIqt13XGC5oSj60ToE/g">ARpRaxgk4Eg5Ssh8jV4w8BDdKjFDZ1pD3V6P6PJRtiJMpTXckmw=</string>
57+
<string name="AUh4VNLOvgbmqRDmi7BBk8+/1F/FJ7H6rsoNl2B3MBl/7g==">ARpRaxipnE2qdflE/X7dQYbNBtu7NxptAfmdz8+J/lBODO0kqSU=</string>
58+
<string name="AUh4VNK3nOPZuU3qgLFBAX1rs08LgLF3DKeCCbNK">ARpRaxghDuvQTvR+sH3qge7h9t7SZH4WITftmnA9jpZuizdDTzE=</string>
59+
<string name="AUh4VNJ6aLMPosbF9bIT1f8h3KkBDKsNjH3TNa/9">ARpRaxgTIDlUlcqBurlhjMIBiWdYd/Iv/XafyPYAX+4FbElm+b8yEys=</string>
60+
</map>
61+
```
62+
63+
Add the required dependencies to your build.gradle file:
64+
65+
```groovy
66+
dependencies {
67+
implementation("androidx.security:security-crypto:1.1.0-alpha06")
68+
}
69+
```
70+
```kotlin
71+
fun init(context : Context) {
72+
73+
val masterKeyAlias = MasterKey.Builder(context)
74+
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
75+
.build()
76+
77+
this.preferences = EncryptedSharedPreferences.create(
78+
context,
79+
SHARED_PREFERENCE_FILE_NAME,
80+
masterKeyAlias,
81+
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
82+
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
83+
)
84+
85+
}
86+
```
87+
88+
89+
90+
91+

0 commit comments

Comments
 (0)