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

Updating Password Not Working #25

Closed BhimAle closed 9 years ago

BhimAle commented 9 years ago

While using one static key , it is working as charm, but my situation is bit different, need to change the key often. So I tried to use

    SecurePreferences securePrefs = new SecurePreferences(context, "userpassword", "my_user_prefs.xml");
    securePrefs.handlePasswordChange("newPassword", context);

But not working.

scottyab commented 9 years ago

Ok thanks @BhimAle More correctly here's the example / test that fails....

 public void testChangeUserPassword() {
        SecurePreferences securePrefs = new SecurePreferences(getContext(), "myfirstpassword", USER_PREFS_WITH_PASSWORD);
        Editor editor = securePrefs.edit();
        final String key = "pwchgfoo";
        final String value = "pwchgbar";
        editor.putString(key,value);
        editor.commit();
        securePrefs.handlePasswordChange("newPassword", getContext());

        String valueFromNewPassword = securePrefs.getString(key, null);
          assertEquals(value, valueFromNewPassword);
    }
scottyab commented 9 years ago

@BhimAle this is fixed in master branch and will be included in 0.1.3 release.

BhimAle commented 9 years ago

@scottyab ok Thank You very much :)