gpt4 book ai didi

swift - Swift 用户登录的最佳方式

转载 作者:行者123 更新时间:2023-11-30 13:27:37 25 4
gpt4 key购买 nike

我想制作一个用户必须登录的应用程序。我想问一下使用 NSUserDefaults 还是 CoreData 是否更好、更安全?或者有没有更安全、更好的方法来做到这一点?

编辑:

我如何实际检查密码是否适合特定用户?我现在拥有的是:

 @IBAction func loginPressed(sender: AnyObject) {
if(txtUsername.text == "" || txtPassword.text == "" || txtUsername.text!.characters.count < 5 || txtPassword.text!.characters.count < 6){
let alert = UIAlertController(title: "Failure", message: "Too short password or username", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}else if(txtUsername.text!.characters.count > 5 && txtPassword.text!.characters.count > 6) {
//Here i want to check if the password for the specific user is the right one
}

}

@IBAction func registrationPressed(sender: AnyObject) {
username = txtUsername.text!
password = txtPassword.text!
do {
try
Locksmith.saveData(["Password" : password], forUserAccount: username)
}catch{
print("ERROR");
}
}

最佳答案

我认为你不应该使用任何这些框架,而是在 Github 上下载这个“Keychain”框架。它使用加密技术来存储要保存在钥匙串(keychain)文件系统中的持久数据。

单击此链接下载类(class)。

Keychain Class by Kishikawa Katsumi

关于swift - Swift 用户登录的最佳方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36970514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com