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

SecurePreferences.getInt throw java.lang.ClassCastException:null #62

Open pzl237 opened 7 years ago

pzl237 commented 7 years ago

My app uses the version 0.1.4. Recently, I met a problem: call SecurePreferences. getInt() method, throw "Java. Lang. ClassCastException: null". I find in source code, and find the decrypt (final String ciphertext) method may return null, so the Integer. ParseInt (null) method would throw this exception. I think SecurePreferences. getInt (String key, int defaultValue) method should take the initiative to throw an exception, life for SecurePreferences. getInt (String key, int defaultValue) method throws a NumberFormatException, so that the caller can try catch this a NumberFormatException exception.

alkaaf commented 6 years ago

i got this error too, it is very rare tho. idk what happened but seems it failed to decipher the encrypted string causing Integer.parseInt fail to parse.