Fork me on GitHub

Alex Rupérez

Published: 04 Apr 11:24
View on GitHub


🔐 Secure Property Storage

Helps you define secure storages for your properties using Swift property wrappers.

Twitter Swift License Swift Package Manager compatible Carthage compatible Swift Action Build Status Build Status CodeBeat Coverage

🌟 Features

All keys are hashed using SHA512 and all values are encrypted using AES-GCM to keep user information safe, automagically. Symmetric key and nonce, are stored in Keychain in a totally secure way.


This property wrapper will store your property in UserDefaults using StoreKey (any String but i recommend you a String typed enum).

@UserDefault(<#StoreKey#>) var yourProperty: YourType?

UserDefaultsStorage is also available, a subclass of UserDefaults with all the security provided by this library.


This property wrapper will store your property in Keychain using StoreKey.

@Keychain(<#StoreKey#>) var yourProperty: YourType?

As UserDefaultsStorage, KeychainStorage is also available.


This property wrapper will store your property in a memory singleton, every property with the same wrapper and key can access or modify the value from wherever it is.

@Singleton(<#StoreKey#>) var yourProperty: YourType?

As KeychainStorage, SingletonStorage is also available.


This is a custom wrapper, you can define your own Storage protocol implementation.

@Store(<#Storage#>, <#StoreKey#>) var yourProperty: YourType?

As SingletonStorage, DelegatedStorage is also available with all the magic of this library.

🛠 Compatibility

  • macOS 10.15+
  • iOS 13.0+
  • iPadOS 13.0+
  • tvOS 13.0+
  • watchOS 6.0+

⚙️ Installation

You can use the Swift Package Manager by declaring SecurePropertyStorage as a dependency in your Package.swift file:

.package(url: "", from: "0.1.0")

You have a series of products that you can choose:

  • SecurePropertyStorage: All property wrappers, by default.
  • UserDefault: @UserDefault property wrapper.
  • Keychain: @Keychain property wrapper.
  • Singleton: @Singleton property wrapper.
  • Storage: @Store property wrapper.

For more information, see the Swift Package Manager documentation.

Or you can use Carthage:

github "alexruperez/SecurePropertyStorage"

🍻 Etc.

  • Featured in Dave Verwer's iOS Dev Weekly - Issue 450, thanks Dave!
  • Contributions are very welcome.
  • Attribution is appreciated (let's spread the word!), but not mandatory.

👨‍💻 Author

Alex Rupérez –

👮‍♂️ License

SecurePropertyStorage is available under the MIT license. See the LICENSE file for more info.