Vik*_*uli 11 obfuscation android sharedpreferences
我正在尝试使用更安全的方式编辑用户的共享首选项集EncryptedSharedPreferences
private fun provideSecureSharedPreference(context: Context): SharedPreferences {
val masterKey = MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build()
return EncryptedSharedPreferences.create(
context, "secret_shared_prefs", masterKey, EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
}
Run Code Online (Sandbox Code Playgroud)
当我使用时它运行良好minifyEnabled false
现在我正在尝试通过执行以下操作来混淆代码minifyEnabled true
为了避免其他错误,现在我只将这些行放入我的proguard-rules.pro
文件中
-dontobfuscate
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*,!code/allocation/variable
Run Code Online (Sandbox Code Playgroud)
但问题是当我设置时minifyEnable true
我得到
java.io.FileNotFoundException: can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist
Run Code Online (Sandbox Code Playgroud)
我尝试从 Stackoverflow 和其他渠道搜索旧帖子,但找不到解决方案。寻求帮助谢谢。
我设法摆脱了这条消息:
java.io.FileNotFoundException:无法读取键集;首选项值androidx_security_crypto_encrypted_prefs_key_keyset不存在
使用1.1.0-alpha06版本,其中显示:
将 Tink 依赖项更新为 1.8.0
因此,将其添加到您的应用程序中build.gradle
:
implementation "androidx.security:security-crypto:1.1.0-alpha06"
Run Code Online (Sandbox Code Playgroud)
另一种选择是使用 crypto stable 1.0.0版本和 Tink 1.8.0 版本,直到security-crypto:1.1.0
发布:
implementation "androidx.security:security-crypto:1.0.0"
implementation "com.google.crypto.tink:tink-android:1.8.0"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3245 次 |
最近记录: |