secure-preferences
secure-preferences copied to clipboard
Hashing the keys broke the getAll() and onSharedPreferenceChanged(SharedPreferences, String) methods
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.
@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.