Skip to content

sabapathy7/KeychainServicesExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

iOS Keychain Services

Overview

This iOS app demonstrates the usage of Keychain services for secure storage and retrieval of sensitive information, such as passwords. The app provides functionality to save, fetch, update, and delete passwords securely using Apple's Keychain services.

Features

  • Save Password: securely store passwords in the Keychain.
  • Fetch Password: retrieve saved passwords from the Keychain.
  • Update Password: update existing passwords in the Keychain.
  • Delete Password: remove passwords from the Keychain.

Animated Gif

Simulator Screen Recording - iPhone 15 Pro - 2024-01-10 at 00 06 12

Installation

  1. Clone the repository:

    git clone https://github.com/sabapathyk7/KeychainServicesExample.git
  2. Open the Xcode project:

    cd KeychainServicesExample
    open KeychainServicesExample.xcodeproj
  3. Build and run the app on a simulator or physical device.

Examples

Saving a Password:

 let addKeychainStatus = SecItemAdd(attributes as CFDictionary, nil)
    switch addKeychainStatus {
    case errSecSuccess:
        break
    case errSecDuplicateItem: // Update the password in keychain
        try updatePasswordFor(username: username, newPassword: password)
    default:
        throw KeychainError(status: addKeychainStatus, type: .servicesError)
    }

Updating a Password:

 let updateKeychainItemStatus = SecItemUpdate(query as CFDictionary, attributes as CFDictionary)

Fetching a Password:

 let searchStatus = SecItemCopyMatching(query as CFDictionary, &item)

Deleting the password:

 let deleteKeychainItemStatus = SecItemDelete(query as CFDictionary)

Acknowledgments

Apple Keychain Services Documentation

Connect with Me

Stay updated on the latest features and releases by following me on LinkedIn.