ios – 如果kSecAttrIsPermanent设置为NO会发生什么?

在iOS上使用Apples libcommonCrypto.dylib时,kSecAttrIsPermanent属性用法是什么?

Apples documentation说:

The corresponding value is of type CFBooleanRef and indicates whether
this cryptographic key is to be stored permanently.

是什么原因不能永久存储钥匙串中的东西以及存储多长时间? (直到重启?直到应用程序关闭?直到应用程序被卸载?)

解决方法

它是生成密钥时SecKeyGeneratePair中使用的参数.

Certificate,Key,and Trust Services Reference

kSecAttrIsPermanent — If this key is present and has a Boolean value of true,the key or key pair is added to the default keychain.

在这种情况下,如果您提供此参数并且它为false,那么您将在内存中接收密钥,但它不会持久保存到密钥链(磁盘上).在应用程序仍在运行时,它会持续很长时间,除非你自己坚持下去.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...