Skip to content

Commit

Permalink
Small fix to generatePassphrase to avoid overwriting the key.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamuno committed May 14, 2020
1 parent fd1c35e commit 5a9a026
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5a9a026

Please sign in to comment.