fix: don't double encrypt on save

This commit is contained in:
Harris 2021-06-07 12:00:21 +10:00
parent 91aefb7c87
commit 596b02cfaf

View File

@ -139,7 +139,12 @@ public class IdentityKeyUtil {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
KeyStoreHelper.SealedData encryptedSecret = KeyStoreHelper.seal(value.getBytes());
preferencesEditor.putString(key+ENCRYPTED_SUFFIX, encryptedSecret.serialize());
boolean isEncryptedSuffix = key.endsWith(ENCRYPTED_SUFFIX);
if (isEncryptedSuffix) {
preferencesEditor.putString(key, encryptedSecret.serialize());
} else {
preferencesEditor.putString(key+ENCRYPTED_SUFFIX, encryptedSecret.serialize());
}
} else {
preferencesEditor.putString(key, value);
}