
Encrypted Storage Guide - EncryptedSharedPreferences & KeyStore
Encrypted Storage Guide - EncryptedSharedPreferences & KeyStore Secure sensitive data using encryption. EncryptedSharedPreferences provides transparent encryption. Dependencies dependencies { implementation ( "androidx.security:security-crypto:1.1.0-alpha06" ) } EncryptedSharedPreferences Setup class SecurePreferencesRepository ( context : Context ) { private val masterKey = MasterKey . Builder ( context ) . setKeyScheme ( MasterKey . KeyScheme . AES256_GCM ) . build () private val encryptedPreferences = EncryptedSharedPreferences . create ( context , "secret_prefs" , masterKey , EncryptedSharedPreferences . PrefKeyEncryptionScheme . AES256_SIV , EncryptedSharedPreferences . PrefValueEncryptionScheme . AES256_GCM ) fun savePassword ( password : String ) { encryptedPreferences . edit (). putString ( "password" , password ). apply () } fun getPassword (): String ? = encryptedPreferences . getString ( "password" , null ) } EncryptedFile for Sensitive Files class SecureFileRepository ( con
Continue reading on Dev.to Tutorial
Opens in a new tab



