Latest 3.0.0
Homepage https://github.com/phimage/CryptoPrephirences
License MIT
Platforms ios 9.0, osx 10.11, tvos 10.0, watchos 3.0
Dependencies CryptoSwift, Prephirences
Authors

License
Platform
Language
Issues
Cocoapod
Join the chat at https://gitter.im/phimage/Prephirences

CryptoPrephirences CryptoPrephirences allows you to protect your preferences against unauthorized access and modification.

preferences["aKey", .cipher(cipher)] = "myValueToEncrypt"

It’s build on top Prephirences and CryptoSwift

Installation

Support CocoaPods

  • Podfile
use_frameworks!

pod "CryptoPrephirences"

Usage

To Encrypt and decrypt data, you will need a CryptoSwift.Cipher, see CryptoSwift documentation to create one.

Encrypt/Decryp each key/value independently

Store any NSCoding object compliant

You can store one preference using

var preferences = UserDefaults.standard
preferences["aKey", .cipher(cipher)] = value
preferences.set(value, forKey: "aKey", withCipher: cipher)

Get the decrypted value

let value = preferences[key, .cipher(cipher)]
let value = preferences.object(forKey: key, withCipher: cipher)

Encrypted Plist file

Using this method key and values will be encrypted.

You can read and write your preferences to an encrypted file using :

try anyPreferences.saveTo(filePath: "/path/to/file", withCipher:cipher)

try mutablePreferences.loadFrom(filePath: "/path/to/file", withCipher: cipher)

You can also initialize a DictionaryPreferences with cipher

let pref = try DictionaryPreferences(filePath: filePath, withCipher: cipher)

Encrypted all values

You can use the CryptoPrephirences, which work as a proxy of another Prephirences and encrypt/decrypt using the given cipher

var cryptoPreferences = MutableCryptoPrephirences(preferences: mutablePreferences, cipher: cipher)
// or for read-only CryptoPrephirences(preferences: anyPreferences, cipher: cipher)

Latest podspec

{
    "name": "CryptoPrephirences",
    "version": "3.0.0",
    "summary": "Add some encryption to your sensitive preferences",
    "homepage": "https://github.com/phimage/CryptoPrephirences",
    "license": "MIT",
    "authors": {
        "phimage": "[email protected]"
    },
    "platforms": {
        "ios": "9.0",
        "osx": "10.11",
        "tvos": "10.0",
        "watchos": "3.0"
    },
    "source": {
        "git": "https://github.com/phimage/CryptoPrephirences.git",
        "tag": "3.0.0"
    },
    "default_subspecs": "Core",
    "dependencies": {
        "CryptoSwift": [],
        "Prephirences": []
    },
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Sources/*.swift"
        }
    ]
}

Pin It on Pinterest

Share This