https://github.com/groupeminaste/keychain.swift
The easiest way to securely store data in the keychain. It's implementation is really close to the UserDefaults.
https://github.com/groupeminaste/keychain.swift
keychain keychain-wrapper spm swift
Last synced: 12 months ago
JSON representation
The easiest way to securely store data in the keychain. It's implementation is really close to the UserDefaults.
- Host: GitHub
- URL: https://github.com/groupeminaste/keychain.swift
- Owner: groupeminaste
- License: gpl-3.0
- Created: 2020-05-07T10:54:50.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-21T10:19:55.000Z (almost 5 years ago)
- Last Synced: 2025-06-10T20:04:28.597Z (about 1 year ago)
- Topics: keychain, keychain-wrapper, spm, swift
- Language: Swift
- Size: 30.3 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Keychain
A swift package to easily implement Keychain on your iOS apps, with a UserDefaults-like implementation.
## Installation
Add `https://github.com/GroupeMINASTE/Keychain.swift.git` to your Swift Package configuration (or using the Xcode menu: `File` > `Swift Packages` > `Add Package Dependency`)
## Usage
```swift
// Import the package
import Keychain
// When your need to access the Keychain, initialize it like this:
let keychain = Keychain()
// If you want to use an access group for your Keychain, pass it as a String argument
// let keychain = Keychain(accessGroup: "TEAMID.your.app.identifier")
// To save a value for a key named "yourKey", simply use:
let saved:Bool = keychain.save(5, forKey: "yourKey")
// The returned boolean indicates if the operation was successful
// To read a value for this key
let value = keychain.value(forKey: "yourKey") as? Int ?? 0
// And finally to delete your key and it's value, use:
let deleted:Bool = keychain.remove(forKey: "yourKey")
// The returned boolean indicates if the operation was successful
```