https://github.com/0xwdg/securestorage
SecureStorage is a property wrapper around the keychain to easily access your protected data.
https://github.com/0xwdg/securestorage
0xwdg hacktoberfest keychain propertywrapper securestorage swift swiftui
Last synced: 4 months ago
JSON representation
SecureStorage is a property wrapper around the keychain to easily access your protected data.
- Host: GitHub
- URL: https://github.com/0xwdg/securestorage
- Owner: 0xWDG
- License: mit
- Created: 2025-01-25T14:29:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-13T18:51:55.000Z (over 1 year ago)
- Last Synced: 2026-02-23T10:41:44.864Z (4 months ago)
- Topics: 0xwdg, hacktoberfest, keychain, propertywrapper, securestorage, swift, swiftui
- Language: Swift
- Homepage: https://0xwdg.github.io/SecureStorage/
- Size: 297 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# SecureStorage
SecureStorage is a property wrapper around the keychain to easily access your protected data.
[](https://swiftpackageindex.com/0xWDG/SecureStorage)
[](https://swiftpackageindex.com/0xWDG/SecureStorage)
[](https://swift.org/package-manager)

## Requirements
- Swift 5.9+ (Xcode 15+)
- iOS 13+, macOS 10.15+
## Installation (Pakage.swift)
```swift
dependencies: [
.package(url: "https://github.com/0xWDG/SecureStorage.git", branch: "main"),
],
targets: [
.target(name: "MyTarget", dependencies: [
.product(name: "SecureStorage", package: "SecureStorage"),
]),
]
```
## Installation (Xcode)
1. In Xcode, open your project and navigate to **File** โ **Swift Packages** โ **Add Package Dependency...**
2. Paste the repository URL (`https://github.com/0xWDG/SecureStorage`) and click **Next**.
3. Click **Finish**.
## Usage
```swift
import SwiftUI
import SecureStorage
struct ContentView: View {
// For this example, we directly bind the username & password.
// This is not smart to do, because you'll overwrite the values as you type.
@SecureStorage("username")
var username: String?
@SecureStorage("password")
var password: String?
var body: some View {
VStack {
Text("Please login")
TextField("Username", text: $username ?? "")
SecureField("Password", text: $password ?? "")
Button("Login") {
print("Login", username, password)
}
Button("Delete username") {
SecureStorage("username").delete()
}
Button("Delete password") {
SecureStorage("password").delete()
}
Button("Delete username") {
SecureStorage("*").deleteAll()
}
}
}
}
```
## Contact
๐ฆ [@0xWDG](https://bsky.app/profile/0xWDG.bsky.social)
๐ [mastodon.social/@0xWDG](https://mastodon.social/@0xWDG)
๐ฆ [@0xWDG](https://x.com/0xWDG)
๐งต [@0xWDG](https://www.threads.net/@0xWDG)
๐ [wesleydegroot.nl](https://wesleydegroot.nl)
๐ค [Discord](https://discordapp.com/users/918438083861573692)
Interested learning more about Swift? [Check out my blog](https://wesleydegroot.nl/blog/).