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.
1.53k stars 235 forks source link

First time initialization with an empty string as password is very slow, it typically takes 4 seconds on every device #64

Open Rkdroid opened 7 years ago

Rkdroid commented 7 years ago

private SecurePreferences mSecurePrefs;
private SecurePreferences openSharedPrefs(){ if (mSecurePrefs == null) { mSecurePrefs = new SecurePreferences(context, "", "sec_prefs.xml"); } return mSecurePrefs; }

Usage: PreferenceManager pref = new SharedPreferencesManager(context); String text = pref.getText(); The first time initialisation of preferences takes lot of time, on average 4 seconds, which is really frustrating for the user. have implemented this library at the first time launch of the app and lot of users are complaining that app never loads because of this issue.

Can you please help to improve the speed of initialization with respect to the above scenario.

Thanks

miklendap commented 7 years ago

@Rkdroid See Issue #18 and mentioned PullRequest #48. With this you can significantly reduce initialization time (in my case it was about 50% faster). But unfortunately even if PullRequest #48 was merged at 31 Aug 2016, current version of SecurePreferences (0.1.4) does not contain this changes. So you can fork, or add updated SecurePreferences class directly into your project. Or maybe could @scottyab release new version containing PullRequest #48, couln't he? :smile:

scottyab commented 7 years ago

Let me see what I can do tonight about pushing new release with this change

On Thu, 22 Jun 2017, 13:26 miklendap, notifications@github.com wrote:

@Rkdroid https://github.com/rkdroid See Issue #18 https://github.com/scottyab/secure-preferences/issues/18 and mentioned PullRequest #48 https://github.com/scottyab/secure-preferences/pull/48. With this you can significantly reduce initialization time (in my case it was about 50% faster). But unfortunately even if PullRequest #48 https://github.com/scottyab/secure-preferences/pull/48 was merged at 31 Aug 2016, current version of SecurePreferences (0.1.4) does not contain this changes. So you can fork, or add updated SecurePreferences class directly into your project. Or maybe could @scottyab https://github.com/scottyab release new version containing PullRequest #48 https://github.com/scottyab/secure-preferences/pull/48, couln't he? 😄

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/scottyab/secure-preferences/issues/64#issuecomment-310364955, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYqiSK-c_0WmqZq5MGiTKQY7vJ0A6p9ks5sGl1xgaJpZM4Nh-HW .

miklendap commented 7 years ago

Hi @scottyab, any update with this issue and new Lib version release? Also e.g. issue #31 (crash on API 16) should be solved with new release.

Thanks in advance.

scottyab commented 6 years ago

Hey @miklendap @Rkdroid I'm in the middle of sorting a 0.1.5 release to include the most recent changes. In terms of the slowness that's something I'll be addressing in next version to make it down to the developer to choose fast/less secure or slow/more secure. Thanks for the feedback.

danilodequeiroz commented 6 years ago

You can keep your SecurePreferences instance as a singleton and create it on your Application class along with Fabric and others stuffs, my app has a splash screen (with a drawable in theme's background) so the user won't notice the delay.