A helper for swiftifying the Keychain APIs.
.package(url: "https://github.com/fizker/swift-keychain.git", from: "0.1.0")
to the list of dependencies in your Package.swift file..product(name: "Keychain", package: "swift-keychain")
to the dependencies of the targets that need to use the keychain.import Keychain
in the file and use the types. See the examples or tests for more details at this level.Start by creating a Keychain with the intended item class:
let keychain = Keychain<GenericPasswordKeychainItem>()
then create items on the keychain:
let passwordData = "secret password".data(using: .utf8)!
var item = GenericPasswordKeychainItem(account: "some account key", password: passwordData)
// configure any other things on the item
item.isSynchronizable = true
// then add it to the keychain
try keychain.add(item)
later on, fetch the item again using a query:
let query = GenericPasswordKeychainItem.Query(account: "some account key")
if let item = try keychain.fetch(query) {
let password = String(data: item.password, encoding: .utf8)!
// do something with the password
}
link |
Stars: 0 |
Last commit: 1 year ago |
Initial release. This includes the GenericPasswordKeychainItem
keychain type.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics