gleezr / Slink

Encrypted shared preferences for android
6 stars 1 forks source link

How do you encrypt the shared preferences #4

Open tomrum opened 6 years ago

tomrum commented 6 years ago

"This library gives you the option to write encrypted shared preferences data using the Facebook's Conceal library."

Can you please give an example on how to do this.

Thanks!

tomrum commented 6 years ago

Hello again.

I have done some digging. I assume slink uses conceal by default and uses the encrytion. My issue is that when I use Chrome devtools (see https://stackoverflow.com/a/40464820/1393697) to view the shared preference it is displayed in plaintext.

Would you know whether chrome devtools is unencrypting the preference automatically? I have no other way to view the preference to indeed see whether it is encryped.

Many thanks if you can help :-)

tomrum commented 6 years ago

Not impressed when people create a library and don't answer issues! Also this library is now crashing my app:

E/AndroidRuntime: FATAL EXCEPTION: SharedPreferencesImpl-load Process: com.., PID: 16304 com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ at com.google.gson.Gson.fromJson(Gson.java:899) at com.google.gson.Gson.fromJson(Gson.java:852) at com.google.gson.Gson.fromJson(Gson.java:801) at com.gleezr.slink.Slink.loadFromDisk(Slink.java:177) at com.gleezr.slink.Slink.access$000(Slink.java:57) at com.gleezr.slink.Slink$1.run(Slink.java:113) Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385) at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:183) at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145) at com.google.gson.Gson.fromJson(Gson.java:887) at com.google.gson.Gson.fromJson(Gson.java:852)  at com.google.gson.Gson.fromJson(Gson.java:801)  at com.gleezr.slink.Slink.loadFromDisk(Slink.java:177)  at com.gleezr.slink.Slink.access$000(Slink.java:57)  at com.gleezr.slink.Slink$1.run(Slink.java:113)

Going to uninstall this library now and use standard shared preferences!