All Projects → puretears → KeychainWrapper

puretears / KeychainWrapper

Licence: MIT License
A lightweight, pure-Swift library for the iOS keychain.

Programming Languages

swift
15916 projects
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to KeychainWrapper

MIDIKit
🎹 Modern multi-platform Swift CoreMIDI wrapper with MIDI 2.0 support.
Stars: ✭ 26 (-49.02%)
Mutual labels:  swift5
NYTimes-iOS
🗽 NY Times is an Minimal News 🗞 iOS app 📱 built to describe the use of SwiftSoup and CoreData with SwiftUI🔥
Stars: ✭ 152 (+198.04%)
Mutual labels:  swift5
SETabView
SETabView is a TabBar with simple yet beautiful animations that makes your apps look cool!
Stars: ✭ 53 (+3.92%)
Mutual labels:  swift5
SwiftUI-Tooltip
Easy Tooltip for your SwiftUI Project
Stars: ✭ 130 (+154.9%)
Mutual labels:  swift5
ACarousel
A carousel view for SwiftUI | SwiftUI 旋转木马效果
Stars: ✭ 124 (+143.14%)
Mutual labels:  swift5
swift-standard-clients
Client declarations and live implementations for standard iOS managers
Stars: ✭ 28 (-45.1%)
Mutual labels:  keychain
Shift
Light-weight EventKit wrapper.
Stars: ✭ 31 (-39.22%)
Mutual labels:  swift5
SSCustomSideMenu
Side Menu Custom Control for iOS apps
Stars: ✭ 50 (-1.96%)
Mutual labels:  swift5
LAPSforMac
Local Administrator Password Solution for Mac
Stars: ✭ 29 (-43.14%)
Mutual labels:  keychain
lockd
Generate strong passwords and save them in Keychain. Made with SwiftUI
Stars: ✭ 38 (-25.49%)
Mutual labels:  keychain
Setup-Xcode-Derived-Data-RAM-Disk
Swift Script: Get the fastest build times in Xcode. This repository accompanies my article linked here:
Stars: ✭ 118 (+131.37%)
Mutual labels:  swift5
Extras
Just some extras..
Stars: ✭ 17 (-66.67%)
Mutual labels:  swift5
MBVideoPlayer
A video player on top of AVQueuePlayer with custom header, playlist items, play, pause, seek to slider, time, resize to fullscreen, forward, backward horizontal, vertical capabilities.
Stars: ✭ 103 (+101.96%)
Mutual labels:  swift5
OnlySwitch
⚙️ All-in-One menu bar app, hide 💻MacBook Pro's notch, dark mode, AirPods, Shortcuts
Stars: ✭ 1,288 (+2425.49%)
Mutual labels:  swift5
Swift-IOS-ANE
FlashRuntimeExtensions.swift. Example Air Native Extension written in Swift 5 for iOS, macOS and tvOS
Stars: ✭ 56 (+9.8%)
Mutual labels:  swift5
Swift101
That contains various information and examples about the basics of Swift Programming. 💻 📱 📺 ⌚️
Stars: ✭ 28 (-45.1%)
Mutual labels:  swift5
SwiftBrick
swift砖块系列:UI基础框架,有各种工具方便快速搭建APP
Stars: ✭ 19 (-62.75%)
Mutual labels:  swift5
StoryboardPreviewsBySwiftUI
Introduce how to make the Storyboard file and Xib file correspond to the preview function by SwiftUI.
Stars: ✭ 35 (-31.37%)
Mutual labels:  swift5
Deviice
Swift library to easily check the current device and some more info about it.
Stars: ✭ 51 (+0%)
Mutual labels:  swift5
Fab
🛍️ A Floating Action Button for macOS. Inspired by Material Design, and written in Swift.
Stars: ✭ 24 (-52.94%)
Mutual labels:  swift5

KeychainWrapper

codebeat badge

KeychainWrapper is a light weight swift wrapper for iOS keychain. Makes accessing keychain is exetremely simple as UserDefaults. It is motivated by creating the app of boxueio.com.

Features

  • Fully tested.
  • Simple interface.
  • Support access group.
  • Support accessibility.
  • Updated to Swift 5.

KeychainWrapper 101

The simplest use case is using the default singleton. Then save and load data as the way of manipulating UserDefaults.

Add values to keychain. All these set methods return Bool to indicate if the data was saved successfully. If the key already exists, the data will be overritten.

/// Save data
KeychainWrapper.default.set(1, forKey: "key.int.value")
KeychainWrapper.default.set([1, 2, 3], forKey: "key.array.value")
KeychainWrapper.default.set("string value", forKey: "key.string.value")

Retrieve values from keychain. All kinds of getter methods return T?, if the data corresponding to forKey cannot decoded back to T, it returns nil.

/// Load data
KeychainWrapper.default.object(of: Int.self, forKey: "key.int.value")
KeychainWrapper.default.object(of: Array.self, forKey: "key.array.value")
KeychainWrapper.default.string(forKey: "key.string.value")

Remove data from keychain. Return Bool indicating if the delete was successful.

KeychainWrapper.default.removeObject(forKey: "key.to.be.deleted")

Customization

Specify service name

When you use the default KeychainWrapper object, all keys are linked to your main bundle identifier as the service name. Howerver, you could change it as follows:

let serviceName = "Custom.Service.Name"
let myWrapper = KeychainWrapper(serviceName: serviceName)

Specify access group

You may also share keychain items by a customized access group:

let serviceName = "Custom.Service.Name"
let accessGroup = "Shared.Access.Group"
let myWrapper = KeychainWrapper(serviceName: serviceName, accessGroup: accessGroup)

The default KeyChainWrapper object do not share any keychain item and its accessGroup is nil.

Accessibility

By default, all items saved by KeychainWrapper can only be access when the device is unlocked. The enum KeychainItemAccessibility gives you a customization point to specify another accessibility level.

KeychainWrapper.default.set(1, forKey: "key.int.value", withAccessibility: .afterFirstUnlock)

The kSecAttrAccessibleAlways and kSecAttrAccessibleAlwaysThisDeviceOnly are deprecated by iOS 12.0. So we do not include them in KeychainItemAccessibility.

Installation

To integrate KeychainWrapper into your Xcode project using Carthage, speicify the following line in your Cartfile:

github "puretears/KeychainWrapper" ~> 1.0

Video sessions

We also recorded some videos talking about keychain basic and KeychainWrapper implementation details (Chinese 🇨🇳, Subscription needed).

  1. Keychain basics
  2. Keychain implementation - I
  3. Keychain implementation - II
  4. Orgnize test cases for KeychainWrapper
  5. Keychain implementation - III
  6. Decorate your README.md

Requirements

  • iOS 10.0+
  • Swift 4.0+

Next Steps

  • Cocoapods and SPM support;
  • mac OS support;
  • iCloud sharing support;
  • More detailed granularity of exception heirarchy, instead of using just false or nil to indicate errors.

Release History

  • 1.0
    • Initial release

License

KeychainWrapper is released under the MIT license. See LICENSE for details.

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].