Naibeck / Android-Security

A sample repo that will cover the new AndroidX security, and some other tools that Android provides to secure your data.
7 stars 3 forks source link

Request: update repository #1

Open AndroidDeveloperLB opened 4 years ago

AndroidDeveloperLB commented 4 years ago

Seems MasterKeys.getOrCreate is deprecated. It says to use MasterKey.Builder instead:

image

Can you please update it?

Also, I think the minimal API for androidx.security:security-crypto:1.1.0-alpha02, is now 21.

AndroidDeveloperLB commented 4 years ago

I think this can be done as such:

val masterKey = MasterKey.Builder(context, MasterKey.DEFAULT_MASTER_KEY_ALIAS).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build()

And to get the sharedPreferences of it:

EncryptedSharedPreferences.create(context, fileName, masterKey,
                    EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
                    EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
            )