Skip to content

A sane way to work with the iOS Keychain in Swift.

License

Notifications You must be signed in to change notification settings

getcircle/Locksmith

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Locksmith

A sane way to work with the iOS Keychain in Swift.

Usage

Install the framework ([reference](https://github.com/Alamofire/Alamofire#installation for reference)).

Note: Due to a bug in Swift, the Swift Compiler - Code Generation Optimization Level for release builds has to be set to -Onone. Go here for more infromation on how to change it.

Quick Start

Save Data

Locksmith.saveData(["some key": "some value"], forKey: key, inService: service, forUserAccount: userAccount)

Load Data

let (dictionary, error) = Locksmith.loadData(forKey: key, inService: service, forUserAccount: userAccount)

Update Data

Locksmith.updateData(["some key": "another value"], forKey: key, inService: service, forUserAccount: userAccount)

Delete Data

Locksmith.deleteData(forKey: key, inService: service, forUserAccount: userAccount)

Custom Requests

To create custom keychain requests, you first have to instantiate a LocksmithRequest. This request can be customised as much as required. Then callLocksmith.performRequest on that request.

Saving

let saveRequest = LocksmithRequest(service: service, userAccount: userAccount, key: key, data: ["some key": "some value"])
Locksmith.performRequest(saveRequest)

Reading

let readRequest = LocksmithRequest(service: service, userAccount: userAccount, key: key)
let (dictionary, error) = Locksmith.performRequest(readRequest)

Deleting

let deleteRequest = LocksmithRequest(service: service, userAccount: userAccount, key: key, requestType: .Delete)
Locksmith.performRequest(deleteRequest)

LocksmithRequest

More to come.

Required

var service: String
var key: String
var userAccount: String
var type: RequestType  // Defaults to .Read

Optional

var group: String?  // Used for keychain sharing
var data: NSDictionary?  // Used only for write requests
var matchLimit: MatchLimit  // Defaults to .One

About

A sane way to work with the iOS Keychain in Swift.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 96.1%
  • C++ 3.9%