如何保护NSUserDefaults? [英] How to secure NSUserDefaults?

查看:161
本文介绍了如何保护NSUserDefaults?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apple建议使用NSUserDefaults存储您的所有应用偏好设置。但是,似乎NSUserDefaults很容易编辑。有没有办法确保这一点。我不是在寻找一种方法来让它无法编辑,只是让它变得更难以使用户不会那么想改变应用程序内部变量。

Apple advise using NSUserDefaults to store all your app preferences. However, it seems that NSUserDefaults is very easily editable. Is there a way to secure this. I'm not looking for a way to make it impossible to edit, just making it harder so that users won't be so tempted to change application internal variables.

推荐答案

如果一条数据不敏感(例如,默认字体大小),请将其存储在NSUserDefaults中。

If a piece of data is not sensitive (e.g., default font size), store it in NSUserDefaults.

如果需要保护免受随意监听(例如,用户密码),请将其存储在钥匙串中。

If it needs to be secure from casual snooping (e.g., user's password), store it in the Keychain.

如果是需要保护用户安全(例如,注册码),您需要自己进行加密,然后将数据存储在任何您喜欢的位置。

If it needs to be secure from the user (e.g., registration code), you will need to roll your own encryption, then store the data wherever you like.

这篇关于如何保护NSUserDefaults?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆