android - Security Auditor 如何保护我的应用程序中的共享首选项数据

标签 android sharedpreferences

如何在我的应用程序中保护 SharedPreferences 数据?

我为此使用了 2 个步骤,但在安全审计中,黑客能够破解我的数据。

1 步-

SharedPreferences sharedPreferences = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();           
editor.putString("key", value);
editor.commit();

2 步 - 使用 SecureSharePreferences

SecurePreferences securePrefs = new SecurePreferences(context, "key", "my_user_prefs.xml");
SharedPreferences.Editor editor =securePrefs.edit();
editor.putString(key, value);
editor.commit();

处理此问题的任何其他方法。

阅读一些答案后,我用加密数据更新了我的代码,但问题仍然存在。安全审计员仍在从应用程序内存中获取应用程序 sharedpreference.file。

SharedPreferences sharedPreferences = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE);
        String keyEncript = EncriptionDecriptionUtils.encriptionOfData(key).toString().trim().replaceAll("\r\n", "");
        String value = sharedPreferences.getString(keyEncript, "").trim().replaceAll("\r\n", "");
        String valuedecript = EncriptionDecriptionUtils.decriptionOfData(value).toString().trim().replaceAll("\r\n", "");
        return valuedecript;

最佳答案

您可以使用 AES 算法加密和解密共享首选项数据。如果您明确打开共享首选项,您将仅获得加密信息。供您引用查看此 Securing SharedPreferences Data using AES algorithm

关于android - Security Auditor 如何保护我的应用程序中的共享首选项数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49671351/

相关文章:

android - 以编程方式检测 Android 中的电源线何时断开连接(USB 或交流充电器)

安卓错误: cannot find symbol class ActionBarActivity

android - 如何为android中 fragment 中的按钮设置onclick监听器

android - 如何限制 LazyColumn 中的项目数?

android - Shared-preferences 仅适用于 Fragment Activity

javascript - 谁能帮我分离世博会应用程序

android - 如何以编程方式重置 android 应用程序中的所有数据?

android - 使用复选框在自定义 ListView 中保存复选框的状态

Android 博客应用程序,我应该使用 Sharedpreferences 还是 Intents?

Android 服务 getSharedPreferences 问题