简体   繁体   English

如何使用密码保护Mac应用程序?

[英]How to secure a Mac Application with a password?

i am currently trying to secure my Objective-c application with a password. 我目前正在尝试使用密码保护我的Objective-c应用程序。 What I want is a window(or similiar..) popping up whenever the application is launched. 我想要的是每当启动应用程序时弹出一个窗口(或类似窗口)。 Only if the password is right shall the user be able to use the program. 只有密码正确,用户才可以使用该程序。 How to encrypt the string properly? 如何正确加密字符串? I don't want any user to be able to extract it from the content files. 我不希望任何用户能够从内容文件中提取它。 Even though the user should be able to change it once he "logged in". 即使用户“登录”后应该能够对其进行更改。

Thanks in advance. 提前致谢。 I am asking for a hint only :) 我只要求一个提示:)

每当您要存储敏感信息(例如密码)时,请使用Keychain Services

You can create an md5-hash of the password and store that in a file. 您可以创建密码的md5-hash并将其存储在文件中。 If someone else opens this file and sees the hash, it almost impossible to reformat it back to the original password. 如果其他人打开该文件并看到哈希,则几乎不可能将其重新格式化为原始密码。 Now when the user enters a password in your application, make an other md5 hash from that one, and compare if that hash is the same as you stored in the file. 现在,当用户在您的应用程序中输入密码时,从该密码中创建另一个md5哈希,并比较该哈希是否与您存储在文件中的相同。

man 3 md5 for creating md5 hashes on Mac with C code. man 3 md5用于在Mac上使用C代码创建md5哈希。 I don't know any Objective-C wrapper for that, but it should be easy to create it yourself. 我不知道有任何Objective-C包装器,但是您自己创建它应该很容易。

Hope it helps, ief2 希望它有所帮助,ief2

EDIT: Keychain Services is indeed the more "standard" solution 编辑:钥匙串服务确实是更“标准”的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM