Skip to content
This repository has been archived by the owner on Mar 1, 2022. It is now read-only.

Hashing the keys broke the getAll() and onSharedPreferenceChanged(SharedPreferences, String) methods #85

Open
awasisto opened this issue Oct 25, 2018 · 1 comment

Comments

@awasisto
Copy link

The keys returned by the SecurePreferences#getAll() method or passed through the OnSharedPreferenceChangeListener#onSharedPreferenceChanged(SharedPreferences, String) method are the hashed keys instead of the real keys.

Example:

SharedPreferences preferences = new SecurePreferences(getContext());
    
preferences.edit().putString("userBirthPlace", "Mars").apply();
preferences.edit().putString("userFavouriteAnimal", "Unicorn").apply();
    
System.out.println(preferences.getAll());

/*
 * Output: {/ntTe3/atqHnZpVLXZFdZCh1kXCeMNI4ZxZakEmn46M==Unicorn, EKfKV82MWU69SaHA6DzF5LIJ2m6EhElrylXmoC4qFkY==Mars}
 */

I think the keys shouldn't be hashed since they shouldn't contain any user data.

@samratshaw
Copy link

@awasisto I think this is the intended behaviour. The library does not store the keys & uses a hash of the keys for storing the values.

With the current implementation, it is not possible to get the actual keys.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants