Best option to store username and password in android app

前端 未结 10 1893
深忆病人
深忆病人 2020-12-13 06:26

I am developing an Android app where the user needs to sign in to perform operations. But mostly on an android handset, people use \"Keep me signed in\", In

10条回答
  •  失恋的感觉
    2020-12-13 06:59

    You could use EncryptedSharedPreferences from the Jetpack security library. It works great for key-value type settings.

    It wraps SharedPreferences, providing secure encryption/decryption while maintaining the same API as SharedPreferences.

    As in their example:

      String masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC);
    
      SharedPreferences sharedPreferences = EncryptedSharedPreferences.create(
          "secret_shared_prefs",
          masterKeyAlias,
          context,
          EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
          EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
      );
    
      // use the shared preferences and editor as you normally would
      SharedPreferences.Editor editor = sharedPreferences.edit();
    

提交回复
热议问题