diff --git a/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/helpers/KeyGenHelper.java b/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/helpers/KeyGenHelper.java index 884ae33..cff27d9 100644 --- a/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/helpers/KeyGenHelper.java +++ b/app/src/main/java/org/secuso/privacyfriendlyfoodtracker/helpers/KeyGenHelper.java @@ -112,7 +112,10 @@ public static void generateKey(Context context) throws Exception { */ public static void generatePassphrase(Context context) throws Exception { SharedPreferences pref = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE); + String enryptedKeyB64 = pref.getString(ENCRYPTED_KEY, null); + if(enryptedKeyB64 != null) return; + byte[] encryptedKey = rsaEncrypt(generateKeyPassphrase()); enryptedKeyB64 = Base64.encodeToString(encryptedKey, Base64.DEFAULT); SharedPreferences.Editor edit = pref.edit();