GithubHelp home page GithubHelp logo

hanumanabacus / keychainstorage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from radude89/keychainstorage

0.0 1.0 0.0 95 KB

Simple Keychain Wrapper

License: MIT License

Objective-C 1.80% Swift 94.86% Ruby 3.35%

keychainstorage's Introduction

Keychain Storage

build Swift Package Manager Carthage Carthage iOS Twitter: @radude89

Keychain Storage is a simple Keychain wrapper written in Swift.
If you ever wanted to save something in Keychain without writing too much code, you are in the right place.

Requirements

  • iOS 12.0+
  • Xcode 10.2+
  • Swift 5+

Installation

Cocoa Pods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Keychain Storage into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'KeychainStorage', '~> 1.3.0'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate KeychainStorage into your Xcode project using Carthage, specify it in your Cartfile:

github "radude89/KeychainStorage" "1.3.0"

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, you can add KeychainStorage as a dependency by adding it to the dependencies array of your Package.swift.

dependencies: [
    .package(url: "https://github.com/radude89/KeychainStorage.git", from: "1.0.0")
]

Manual

Just drag and drop into your project the following projects found in KeychainStorage:

  • KeychainQueryFactory.swift
  • KeychainStorage.swift
  • KeyValueStorage.swift

Examples

Make sure you try out the small app, the example project found at: Example/KeychainStorageExample.xcworkspace.
Build & run.

Saving a value in Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.set("secret", key: "myStringKey")

try? storage.set(true, key: "myBoolKey")

Retrieving a value from Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")

if let myStringValue = try? storage.string(forKey: "myStringKey") {
    // do something with myStringValue
}

if let myBoolValue = try? storage.bool(forKey: "myBoolKey") {
    // do something with myBoolValue
}

Deleting a value from Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.removeValue(forKey: "myStringKey")

Deleting all values from Keychain

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.removeAll()

License

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

Contributions & support

KeychainStorage is developed as an open source project. I encourage everyone to contribute.

Please do make pull requests if you have suggestions or ideas of improvement.

Thanks!

keychainstorage's People

Contributors

radude89 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.