{"id":13850914,"url":"https://github.com/deniskr/KeychainSwiftAPI","last_synced_at":"2025-07-13T01:31:43.842Z","repository":{"id":18984815,"uuid":"22206284","full_name":"deniskr/KeychainSwiftAPI","owner":"deniskr","description":"This Keychain Swift API library is a wrapper of iOS C Keychain Framework. It allows easily and securely storing sensitive data in secure keychain store.","archived":false,"fork":false,"pushed_at":"2016-02-12T19:35:33.000Z","size":350,"stargazers_count":88,"open_issues_count":3,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-22T05:30:20.454Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deniskr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-24T09:00:26.000Z","updated_at":"2023-11-15T02:49:00.000Z","dependencies_parsed_at":"2022-08-05T02:01:58.386Z","dependency_job_id":null,"html_url":"https://github.com/deniskr/KeychainSwiftAPI","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/deniskr/KeychainSwiftAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniskr%2FKeychainSwiftAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniskr%2FKeychainSwiftAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniskr%2FKeychainSwiftAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniskr%2FKeychainSwiftAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deniskr","download_url":"https://codeload.github.com/deniskr/KeychainSwiftAPI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deniskr%2FKeychainSwiftAPI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265080005,"owners_count":23708098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T21:00:29.172Z","updated_at":"2025-07-13T01:31:43.530Z","avatar_url":"https://github.com/deniskr.png","language":"Swift","funding_links":[],"categories":["Swift 库"],"sub_categories":[],"readme":"# KeychainSwiftAPI\n\nThis Keychain Swift API library is a wrapper of iOS C Keychain Framework.\nIt allows easily and securely storing sensitive data in secure keychain store\nin Swift projects. Interfacing with the original C keychain API is combersome from\nSwift, and is prone to errors which lead to security vulnerabilities. This\nlibrary is written according to the best security coding practices and guidelines.\n\n## Usage\n\nImport the KeychainSwiftAPI\n```swift\nimport KeychainSwiftAPI\n```\n\nCreate a query object:\n```swift\t\nlet q = Keychain.Query()\n```\n\nPopulate the query object with data. Query properties correspond to attribute keys of the C Keychain API, \nprotery values correspond to attribute values of the C Keychain API. \n\n```swift\nq.kSecClass = Keychain.Query.KSecClassValue.kSecClassGenericPassword\nq.kSecAttrDescription = \"A password from my website\"\nq.kSecAttrGeneric = \"VerySecurePassword\".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)\nq.kSecAttrAccount = \"admin\"\nq.kSecReturnData = true\nq.kSecReturnAttributes = true\nq.kSecReturnRef = true\nq.kSecReturnPersistentRef = true\n```\n\nCall Keychain.secItemAdd, which returns a pair of success code and result object. \n\n```\nlet r = Keychain.secItemAdd(query: q)\n```\n\nSuccess code is wrapped in Keychain.ResultCode enum for convenience.\n\n```\nif (r.status == Keychain.ResultCode.errSecSuccess) {\n    println(\"Password saved. Returned object: \\(r.result)\")\n} else {\n    println(\"Error saving password: \\(r.status.description)\")\n}\n```\n\nr.result contains the object that was retured by the C SecItemAdd underlying function call.\n\n\n## Requirements\n\niOS 8.0 or above\nYou have to use cocoapod compiled from the Swift branch, since the master branch of cocoapods still does not fully support Swift. \nSee: [Using Cocoapods Unreleased Features](http://guides.cocoapods.org/using/unreleased-features)\n\n## Installation\n\nKeychainSwiftAPI is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"KeychainSwiftAPI\"\n```\n\n## Author\n\nDenis Krivitski, denis.krivitski@checkmarx.com\n\n\n## Sponsor\n\n[Checkmarx](http://www.checkmarx.com) LTD. Checkmarx is a provider of code analysis tools, \nstatic code analysis, software code analysis. We help developers make flawless applications.\n\n## License\n\nKeychainSwiftAPI is available under the MIT license. See the LICENSE file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeniskr%2FKeychainSwiftAPI","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeniskr%2FKeychainSwiftAPI","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeniskr%2FKeychainSwiftAPI/lists"}