All Projects → yankodimitrov → Swiftkeychain

yankodimitrov / Swiftkeychain

Licence: mit
An elegant Swift wrapper around the Apple Keychain API

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Swiftkeychain

Go Keychain
Golang keychain package for iOS and macOS
Stars: ✭ 323 (+254.95%)
Mutual labels:  keychain
Ios
Most usable tools for iOS penetration testing
Stars: ✭ 563 (+518.68%)
Mutual labels:  keychain
Instagramkit
The unofficial Instagram iOS SDK
Stars: ✭ 955 (+949.45%)
Mutual labels:  keychain
Macosvpn
🔧 Create macOS VPNs programmatically (L2TP & Cisco)
Stars: ✭ 348 (+282.42%)
Mutual labels:  keychain
Aws Vault
A vault for securely storing and accessing AWS credentials in development environments
Stars: ✭ 5,626 (+6082.42%)
Mutual labels:  keychain
Lthpasscodeviewcontroller
iOS 7 style Passcode Lock
Stars: ✭ 629 (+591.21%)
Mutual labels:  keychain
Xyuuid
iOS14 UUID KeyChain DeviceInfo IDFA UDID
Stars: ✭ 301 (+230.77%)
Mutual labels:  keychain
Keychains
🔑 A keychain wrapper that is so easy to use that your cat could use it.
Stars: ✭ 67 (-26.37%)
Mutual labels:  keychain
Prephirences
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. UserDefaults
Stars: ✭ 548 (+502.2%)
Mutual labels:  keychain
Envchain
Environment variables meet macOS Keychain and gnome-keyring <3
Stars: ✭ 876 (+862.64%)
Mutual labels:  keychain
Simplekeychain
A Keychain helper for iOS to make it very simple to store/obtain values from iOS Keychain
Stars: ✭ 360 (+295.6%)
Mutual labels:  keychain
Securepropertystorage
Helps you define secure storages for your properties using Swift property wrappers.
Stars: ✭ 379 (+316.48%)
Mutual labels:  keychain
Keychaincracker
macOS keychain cracking tool
Stars: ✭ 693 (+661.54%)
Mutual labels:  keychain
Chezmoi
Manage your dotfiles across multiple diverse machines, securely.
Stars: ✭ 5,590 (+6042.86%)
Mutual labels:  keychain
Keychain
A cross-platform wrapper for the OS credential storage
Stars: ✭ 43 (-52.75%)
Mutual labels:  keychain
Gokey
A simple vaultless password manager in Go
Stars: ✭ 305 (+235.16%)
Mutual labels:  keychain
Ellipticcurvekeypair
Sign, verify, encrypt and decrypt using the Secure Enclave
Stars: ✭ 589 (+547.25%)
Mutual labels:  keychain
Ghostunnel
A simple SSL/TLS proxy with mutual authentication for securing non-TLS services
Stars: ✭ 1,296 (+1324.18%)
Mutual labels:  keychain
Node Keytar
Native Password Node Module
Stars: ✭ 1,080 (+1086.81%)
Mutual labels:  keychain
Keychainaccess
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS.
Stars: ✭ 6,611 (+7164.84%)
Mutual labels:  keychain

#SwiftKeychain Carthage compatible

Abstract

Swift wrapper for working with the Keychain API implemented with Protocol Oriented Programming.

You create an implementation of the KeychainGenericPasswordType protocol that encapsulates the data that you want to store in the Keychain. Most of the implementation is done for you by using default protocol implementations, such as setting the default service name and access mode (kSecAttrAccessibleWhenUnlocked).

Then you call the KeychainItemType methods to save, remove or fetch the item from the provided as argument KeychainServiceType protocol implementation.

SwiftKeychain Protocols

Let's say we want to store the access token and username for an Instagram account in the Keychain:

struct InstagramAccount: KeychainGenericPasswordType {
    
    let accountName: String
    let token: String
    var data = [String: AnyObject]()
    
    var dataToStore: [String: AnyObject] {
        return ["token": token]
    }
    
    var accessToken: String? {
        return data["token"] as? String
    }
    
    init(name: String, accessToken: String = "") {
        accountName = name
        token = accessToken
    }
}

In var dataToStore: [String: AnyObject] you return the Dictionary that you want to be saved in the Keychain and when you fetch the item from the Keychain its data will be populated in your var data: [String: AnyObject] property.

Save Item

let newAccount = InstagramAccount(name: "John", accessToken: "123456")

do {
    
    try newAccount.saveInKeychain()

} catch {
    
    print(error)
}

Note: The provided implementation of the KeychainServiceType protocol will replace the item if it already exists in the Keychain database.

Remove Item

let account = InstagramAccount(name: "John")

do {
    
    try account.removeFromKeychain()

} catch {
    
    print(error)
}

Fetch Item

var account = InstagramAccount(name: "John")

do {
    
    try account.fetchFromKeychain()
    
    if let token = account.accessToken {

        print("name: \(account.accountName), token: \(token)")
    }

} catch {

    print(error)
}

Installation

SwiftKeychain requires Swift 2.0 and Xcode 7 and supports iOS, OSX, watchOS and tvOS.

Manually

Copy the Keychain/Keychain.swift file to your project.

Carthage

Add the following line to your Cartfile

github "yankodimitrov/SwiftKeychain" "master"

CocoaPods

Add the following line to your Podfile

pod SwiftKeychain

License

SwiftKeychain is released under the MIT license. See the LICENSE.txt file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].