A lightweight wrapper for UserDefaults that adds AES-256 encryption to secure stored data in iOS/macOS apps.
SecureDefaults is a Swift library that wraps Apple's UserDefaults to add AES-256 encryption, securing stored data in iOS and macOS applications. It solves the problem of sensitive data being stored in plain text within UserDefaults, which can be a security risk if the device is accessed maliciously. By encrypting data with industry-standard cryptographic techniques, it ensures that information like user preferences, tokens, or settings remains protected.
iOS and macOS developers who need to store sensitive data locally in their apps and want to enhance security beyond standard UserDefaults. This includes developers working on apps handling personal user information, authentication tokens, or any confidential data that requires encryption.
Developers choose SecureDefaults because it provides a simple, drop-in replacement for UserDefaults with strong encryption, requiring minimal code changes. Its use of AES-256, PBKDF2, and other cryptographic best practices offers a reliable security layer without the complexity of implementing encryption from scratch.
Elevate the security of your UserDefaults with this lightweight wrapper that adds a layer of AES-256 encryption
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses AES-256 encryption with PBKDF2, salt, and random IV, meeting standards for protecting sensitive data up to SECRET level, as cited from NIST in the README.
Mirrors UserDefaults API closely, allowing easy integration by replacing 'UserDefaults.standard' with 'SecureDefaults.shared' and setting a password, minimizing code changes.
Implements encrypt-then-hash HMAC to verify that encrypted data hasn't been tampered with, enhancing security beyond just encryption.
Supports app and keychain groups via suiteName and keychainAccessGroup properties, enabling shared data across apps in a secure manner.
The README explicitly warns that setting a password multiple times regenerates the key and loses all previous data, which can lead to accidental data loss if not handled carefully.
Only encrypts data stored in UserDefaults; other local storage methods like Core Data or files require separate encryption solutions, limiting comprehensive security coverage.
If the password is lost or corrupted, encrypted data becomes inaccessible with no built-in way to recover, relying entirely on developer-managed backups or fallbacks.
Encryption and decryption processes add computational cost, which might slow down app performance for frequent or large data accesses compared to unencrypted UserDefaults.