SSKeychain

简介:

SSKeychain

https://github.com/soffes/sskeychain

 

SSKeychain is a simple wrapper for accessing accounts, getting passwords, setting passwords, and deleting passwords using the system Keychain on Mac OS X and iOS.

SSKeychain是一个对keychain简易封装的开源库,用以存储用户信息,密码信息等.

 

Adding to Your Project

Simply add the following to your Podfile if you're using CocoaPods:

你可以用CocoaPods安装,在Podfile中写入下面一句话:

pod 'SSKeychain'

or Cartfile if you're using Carthage:

如果你是在使用Carthage,写入下面一句话:

github "soffes/SSKeychain"

To manually add to your project:

或者手动添加到项目当中:

  1. Add Security.framework to your target 添加Security.framework框架
  2. Add SSKeychain.hSSKeychain.mSSKeychainQuery.h, and SSKeychainQuery.m to your project. SSKeychain.hSSKeychain.mSSKeychainQuery.h, 与 SSKeychainQuery.m添加到你的项目当中.

SSKeychain requires ARC.

SSKeychain需要开启ARC.

Note: Currently SSKeychain does not support Mac OS 10.6.

注意:当前的SSKeychain并不支持Mac OS 10.6

 

Working with the Keychain

SSKeychain has the following class methods for working with the system keychain:

SSKeychain有以下的一些方法供你使用:

+ (NSArray *)allAccounts;
+ (NSArray *)accountsForService:(NSString *)serviceName;
+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account; + (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account; + (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account;

Easy as that. (See SSKeychain.h and SSKeychainQuery.h for all of the methods.)

是不是很简单.(你可以在 SSKeychain.h 与 SSKeychainQuery.h 中看到所有相关方法)

 

Documentation

Read the online documentation.

你可以阅读在线文档

 

Debugging

If your saving to the keychain fails, use the NSError object to handle it. You can invoke [error code]to get the numeric error code. A few values are defined in SSKeychain.h, and the rest in SecBase.h.

如果你存储keychain操作失败,请使用NSError来捕获他.

NSError *error = nil;
SSKeychainQuery *query = [[SSKeychainQuery alloc] init];
query.service = @"MyService"; query.account = @"soffes"; [query fetch:&error]; if ([error code] == errSecItemNotFound) { NSLog(@"Password not found"); } else if (error != nil) { NSLog(@"Some other error occurred: %@", [error localizedDescription]); }

Obviously, you should do something more sophisticated. You can just call [error localizedDescription] if all you need is the error message.

 

Disclaimer

Working with the keychain is pretty sucky. You should really check for errors and failures. This library doesn't make it any more stable, it just wraps up all of the annoying C APIs.

 

Thanks

This was originally inspired by EMKeychain and SDKeychain (both of which are now gone). Thanks to the authors. SSKeychain has since switched to a simpler implementation that was abstracted fromSSToolkit.

A huge thanks to Caleb Davenport for leading the way on version 1.0 of SSKeychain.

目录
相关文章
|
2月前
|
存储 安全 算法
【接口加密】Java中的接口加密实践
【接口加密】Java中的接口加密实践
|
2月前
|
小程序 安全 物联网
【经验分享】支付宝小程序常用appId
【经验分享】支付宝小程序常用appId
197 0
|
11月前
|
安全 JavaScript Java
iOS使用PushKit实现VoIP
iOS使用PushKit实现VoIP
608 0
|
网络协议
aws-vpc-对等连接(不同vpc之间的内网互通)
aws-vpc-对等连接(不同vpc之间的内网互通)
1383 0
aws-vpc-对等连接(不同vpc之间的内网互通)
|
3月前
|
机器学习/深度学习 算法 数据挖掘
计算机视觉五大核心研究任务全解:分类识别、检测分割、人体分析、三维视觉、视频分析
计算机视觉五大核心研究任务全解:分类识别、检测分割、人体分析、三维视觉、视频分析
210 1
云服务器经济型e实例99元活动攻略
超详细的续费攻略,帮助你最大限度地低价续费经济型的e实例,新老同享哦
|
6月前
|
存储 安全 开发工具
App隐私合规评估实务和要点
随着移动互联网的高速发展及监管部门针对移动互联网应用程序(以下简称“App”)隐私合规监管趋严,特别是在个人信息保护法的实施下。本文将深入探讨App隐私合规评估的要点和难点,提供详细的信息,并提供一套轻量级和自动化的App隐私合规治理方案,降低App业务被通报和下架等合规风险,以保障企业App业务正常运营。
167 0
|
2月前
|
安全 Java 网络安全
【网络安全 | 扫描器】御剑安装及使用教程详析
【网络安全 | 扫描器】御剑安装及使用教程详析
196 0
|
3月前
|
开发框架 .NET API
C#/.NET/.NET Core推荐学习书籍(23年12月更新)
C#/.NET/.NET Core推荐学习书籍(23年12月更新)
229 0
|
4月前
|
机器学习/深度学习 PyTorch 算法框架/工具
PyTorch深度学习中卷积神经网络(CNN)的讲解及图像处理实战(超详细 附源码)
PyTorch深度学习中卷积神经网络(CNN)的讲解及图像处理实战(超详细 附源码)
108 0

热门文章

最新文章