SecurePropertyStorage alternatives and similar libraries
Based on the "Security" category.
Alternatively, view SecurePropertyStorage alternatives based on common mentions on social networks and blogs.
-
CryptoSwift
CryptoSwift is a growing collection of standard and secure cryptographic algorithms implemented in Swift -
KeychainAccess
Simple Swift wrapper for Keychain that works on iOS, watchOS, tvOS and macOS. -
SAMKeychain
Simple Objective-C wrapper for the keychain that works on Mac and iOS. -
SSKeychain
Simple Objective-C wrapper for the keychain that works on Mac and iOS. -
RNCryptor
CCCryptor (AES encryption) wrappers for iOS and Mac in Swift. -- For ObjC, see RNCryptor/RNCryptor-objc -
Valet
Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works. Itโs easy. We promise. -
UICKeyChainStore
UICKeyChainStore is a simple wrapper for Keychain on iOS, watchOS, tvOS and macOS. Makes using Keychain APIs as easy as NSUserDefaults. -
Locksmith
A powerful, protocol-oriented library for working with the keychain in Swift. -
SwiftKeychainWrapper
A simple wrapper for the iOS Keychain to allow you to use it in a similar fashion to User Defaults. Written in Swift. -
Themis
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms. -
cocoapods-keys
A key value store for storing per-developer environment and application keys -
SwiftPasscodeLock
An iOS passcode lock with TouchID authentication written in Swift. -
Lockbox
Objective-C utility class for storing data securely in the key chain. -
BiometricAuthentication
Use Apple FaceID or TouchID authentication in your app using BiometricAuthentication. -
SwCrypt
RSA public/private key generation, RSA, AES encryption/decryption, RSA sign/verify in Swift with CommonCrypto in iOS and OS X -
LTHPasscodeViewController
iOS 7 style Passcode Lock -
swift-sodium
Safe and easy to use crypto for iOS and macOS -
Smile-Lock
A library for make a beautiful Passcode Lock View -
Obfuscator-iOS
Secure your app by obfuscating all the hard-coded security-sensitive strings. -
TOPasscodeViewController
A modal passcode input and validation view controller for iOS -
SecureEnclaveCrypto
Demonstration library for using the Secure Enclave on iOS -
JOSESwift
A framework for the JOSE standards JWS, JWE, and JWK written in Swift. -
SipHash
Simple and secure hashing in Swift with the SipHash algorithm -
CommonCrypto.swift
:trident: CommonCrypto in Swift, and more -
simple-touch
Very simple swift wrapper for Biometric Authentication Services (Touch ID) on iOS. -
KKPinCodeTextField
A customizable verification code textField. Can be used for phone verification codes, passwords etc -
Virgil Security Objective-C/Swift Crypto Library
Virgil Crypto stack Objective-C/Swift -
iOS-App-Security-Class
Simple class to check if app has been cracked, being debugged or enriched with custom dylib -
Keychain
:key: A keychain wrapper that is so easy to use that your cat could use it. -
Virgil Security Objective-C/Swift SDK
Virgil Core SDK allows developers to get up and running with Virgil Cards Service API quickly and add end-to-end security to their new or existing digital solutions to become HIPAA and GDPR compliant and more. -
SCrypto
Elegant Swift interface to access the CommonCrypto routines -
SweetHMAC
A tiny and easy to use Swift class to encrypt strings using HMAC algorithms. -
BiometricAuth
Framework for biometric authentication (via TouchID) in your application -
TPObfuscatedString
Simple String obfuscation using core Swift. -
RSASwiftGenerator
Util for generation RSA keys on your client and save to keychain or convert into Data ๐ ๐ -
SwiftyKeychainKit
Modern Swift wrapper for Keychain Services API with the benefits of static typing -
Virgil SWIFT PFS SDK
Virgil PFS SDK Objective-C/Swift -
๐ Vault
Simple and Secure container for passwords and other sensitive data. -
VoiceItAPI1IosSDK
A super easy way to add Voice Authentication(Biometrics) to your iOS apps, conveniently usable via cocoapods
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SecurePropertyStorage or a related project?
README
๐ Secure Property Storage
Helps you define secure storages for your properties using Swift property wrappers.
๐ Features
All keys are hashed using SHA512 and all values are encrypted using AES-GCM to keep user information safe, auto*magic*ally. Symmetric key is stored in Keychain in a totally secure way.
๐ Basic usage
@UserDefault
This property wrapper will store your property in UserDefaults using StoreKey
(any String
but i recommend you a String typed enum).
Optionally, you can assign a default value to the property that will be secure stored at initialization.
@UserDefault(<#StoreKey#>)
var yourProperty: YourType? = yourDefaultValueIfNeeded
[UserDefaultsStorage
](Sources/UserDefault/UserDefaultsStorage.swift) is also available, a subclass of UserDefaults
with all the security provided by this library, where you can customize suite name.
@Keychain
This property wrapper will store your property in Keychain using StoreKey
.
@Keychain(<#StoreKey#>)
var yourProperty: YourType? = yourDefaultValueIfNeeded
As UserDefaultsStorage
, [KeychainStorage
](Sources/Keychain/KeychainStorage.swift) is also available, where you can customize access, group and synchronize it with iCloud.
@Singleton
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? = yourDefaultValueIfNeeded
As KeychainStorage
, [SingletonStorage
](Sources/Singleton/SingletonStorage.swift) is also available.
@Inject
This property wrapper is similar to @Singleton
but, together with @Register
, will inject your dependencies. More details in [Dependency Injection usage](#-dependency-injection-usage) guide.
@Inject
var yourDependency: YourProtocol?
As SingletonStorage
, [InjectStorage
](Sources/Inject/InjectStorage.swift) is also available.
@Store
This is a custom wrapper, you can define your own [Storage
](Sources/Storage/Storage.swift) protocol implementation.
@Store(<#YourStorage#>, <#StoreKey#>)
var yourProperty: YourType? = yourDefaultValueIfNeeded
As InjectStorage
, [DelegatedStorage
](Sources/Storage/DelegatedStorage.swift) is also available with all the magic of this library.
๐งโโ๏ธ Codable usage
If your property conforms Codable
protocol, just add Codable
keyword as prefix of your property wrapper.
- @CodableUserDefault
- @CodableKeychain
- @CodableSingleton
- @CodableStore
๐ฅก Unwrapped usage
To avoid continually unwrapping your property, just add Unwrapped
keyword as prefix of your property wrapper, assign a default value (mandatory except for @UnwrappedInject
), and it will return stored value or default value, but your property will always be there for you.
- @UnwrappedUserDefault
- @UnwrappedKeychain
- @UnwrappedSingleton
- @UnwrappedInject
- @UnwrappedStore
๐ฅก + ๐งโโ๏ธ Combo usage
You can also combine previous cases in case you need it, unwrapped first please.
- @UnwrappedCodableUserDefault
- @UnwrappedCodableKeychain
- @UnwrappedCodableSingleton
- @UnwrappedCodableStore
๐ Dependency Injection usage
@Register (click to expand)
This property wrapper will register the implementations of your dependencies.
Register them wherever you want before inject it, but be sure to do it only once (except if you use qualifiers), for example, in an Injector
class.
You can register through a protocol or directly using your class implementation.
@Register
var yourDependency: YourProtocol = YourImplementation()
@Register
var yourDependency = YourImplementation()
You can also define a closure that builds your dependency. Just remember cast your dependency if you are going to inject it through a protocol.
@Register
var yourDependency = {
YourImplementation() as YourProtocol
}
@Register
var yourDependency = {
YourImplementation()
}
@Inject and @UnwrappedInject (click to expand)
These property wrappers injects your dependencies @Register
implementations.
@Inject
var yourDependency: YourProtocol?
@Inject
var yourDependency: YourImplementation?
@UnwrappedInject
var yourUnwrappedDependency: YourProtocol
@UnwrappedInject
var yourUnwrappedDependency: YourImplementation
Scope
Because these property wrappers works similarly to @Singleton
, the default scope is .singleton
, but if you use builder closures on @Register
, you can modify them to inject a single instance.
@Inject(.instance)
var yourDependency: YourProtocol?
@UnwrappedInject(.instance)
var yourUnwrappedDependency: YourProtocol
@InjectWith and @UnwrappedInjectWith (click to expand)
Your dependency may need parameters when injecting, you can pass them with these property wrappers. Simply define a model with your dependency parameters and pass it. It will inject a new instance built with these parameters.
@Register
var yourDependency = { parameters in
YourImplementation(parameters) as YourProtocol
}
@Inject(YourParameters())
var yourDependency: YourProtocol?
@UnwrappedInject(YourParameters())
var yourUnwrappedDependency: YourProtocol
Qualifiers (click to expand)
You can use qualifiers to provide various implementations of a particular dependency. A qualifier is just a @objc protocol
that you apply to a class
.
For example, you could declare Dog
and Cat
qualifier protocols and apply it to another class that conforms Animal
protocol. To declare this qualifier, use the following code:
protocol Animal {
func sound()
}
@objc protocol Dog {}
@objc protocol Cat {}
You can then define multiple classes that conforms Animal
protocol and uses this qualifiers:
class DogImplementation: Animal, Dog {
func sound() { print("Woof!") }
}
class CatImplementation: Animal, Cat {
func sound() { print("Meow!") }
}
Both implementations of the class can now be @Register
:
@Register
var registerDog: Animal = DogImplementation()
@Register
var registerCat: Animal = CatImplementation()
To inject one or the other implementation, simply add the qualifier(s) to your @Inject
:
@UnwrappedInject(Dog.self)
var dog: Animal
@UnwrappedInject(Cat.self)
var cat: Animal
dog.sound() // prints Woof!
cat.sound() // prints Meow!
Testing (click to expand)
One of the advantages of dependency injection is that the code can be easily testable with mock implementation.
That is why there is a Mock
qualifier that has priority over all, so you can have your dependencies defined in the app and create your mock in the test target simply by adding this qualifier.
// App target
class YourImplementation: YourProtocol {}
@Register
var yourDependency: YourProtocol = YourImplementation()
@Inject
var yourDependency: YourProtocol?
// Test target
class YourMock: YourProtocol, Mock {}
@Register
var yourDependency: YourProtocol = YourMock()
๐ Examples
Talk is cheap. Show me the code.
// Securely stored in UserDefaults.
@UserDefault("username")
var username: String?
// Securely stored in Keychain.
@Keychain("password")
var password: String?
// Securely stored in a Singleton storage.
@Singleton("sessionToken")
var sessionToken: String?
// Securely stored in a Singleton storage.
// Always has a value, the stored or the default.
@UnwrappedSingleton("refreshToken")
var refreshToken: String = "B0610306-A33F"
struct User: Codable {
let username: String
let password: String?
let sessionToken: String?
}
// Codable model securely stored in UserDefaults.
@CodableUserDefault("user")
var user: User?
๐ 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: "https://github.com/alexruperez/SecurePropertyStorage", from: "0.3.0")
By default, all property wrappers are installed and you can import
them, but if you want, you can install only some of them:
- UserDefault: @*UserDefault property wrappers.
- Keychain: @*Keychain property wrappers.
- Singleton: @*Singleton property wrappers.
- Storage: @*Store property wrappers.
- Inject: @*Inject property wrappers.
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. Thanks Alberto Garcia and Chen!
- Attribution is appreciated (let's spread the word!), but not mandatory.
๐จโ๐ป Author
Alex Rupรฉrez โ @alexruperez โ [email protected]
๐ฎโโ๏ธ License
SecurePropertyStorage is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
*Note that all licence references and agreements mentioned in the SecurePropertyStorage README section above
are relevant to that project's source code only.