iOS 中关于加密的困惑
我是一个非常新的程序员,试图编写一些 iOS 程序,当我到达必须加密数据的部分时,我遇到了一堵模糊且记录不详的墙。苹果显然提供了加密数据所需的所有工具,但没有在任何地方提及它。目前我正在尝试 https://github.com/AlanQuatermain/aqtoolkit 中找到的东西,这显然有效。但是,我读到 http://robnapier.net/blog/aes-commoncrypto-564 不应使用用户选择的密码作为加密密钥,但我看到了一些人们直接在该库和其他库中使用用户密码的示例。这是否适用于这里,我应该在使用用户密码之前通过一个小的跨栏比赛来运行它吗?
I'm a very newb programmer trying to write some iOS programs, and when I reached the part where I must encrypt my data, I ran into a misty and ill-documented wall. Apple apparently provides all the tools one needs to encrypt data but doesn't write about it anywhere. Currently I am experimenting with stuff found in https://github.com/AlanQuatermain/aqtoolkit, which apparently work. However, I read in http://robnapier.net/blog/aes-commoncrypto-564 that one should not use user selected passwords as encryption keys, but I have seen a few examples of people using the user's password directly with this library and others. Does this apply here, and should I run the user password through a small hurdle race before using it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用密码的哈希值作为加密例程的密钥是一个好主意。原因之一是不同的算法可能需要不同长度的密钥,通过选择适当的哈希算法(例如 AES256 的 SHA256),您会自动获得具有适当长度的密钥。
It is a good idea to use the hash of a password as a key for your crypto routines. One reason for that is that different algorithms may need keys of a different length and by selecting the appropriate hashing algorithm (e.g. SHA256 for AES256) you automatically get a key with the appropriate length.