Latest 1.2.0
Homepage https://github.com/haikieu/NSUserDefaults-SevenSecurityLayers
License MIT
Platforms ios 6.0, osx 10.7, requires ARC
Dependencies CocoaSecurity
Frameworks Foundation
Authors

NSUserDefaults+SevenSecurityLayers.h

  • A category which provides an encryption layer for NSUserDefaults to securely save data .
  • Using strong AES 356-bit encryption

Benefit:

* Secure user data just by one line of code.
* Support obfuscating your key in binary source
* Able to save data without encryption
* Enable to handle exceptional case via built-in NOTIFICATION
* Enable using standardUserDefaults as well as securedUserDefaults parallelly

Make donation for Hai Kieu's github


How to use

Note: Remember to install dependency first


In the implementation file, import NSUserDefaults+SevenSecurityLayers.h

#import "NSUserDefaults+SevenSecurityLayers.h"

Initialize a secured UserDefaults with a secret key.


//Recommend: Should put the secret key in implementation file to secure your key.
//Warning: Must specify the secret key before using or you get **Exception**

NSUserDefault *pref = [[NSUserDefault securedUserDefaults] setSecretKey:@"Your secret key"];

// >>> DONE! That's it, a secured storage has been created already for you to save any data later. <<<

//Demonstrate saving data

[pref setBool:YES forKey:@"DataIsSecured"];
[pref setString:@"AES 356-bit" forKey:@"KindOfEncryption"];
[pref setString:@"v1.2.0 available" forKey:@"ObfuscateSecretKey"];
[pref setString:@"Able to save data without encryption" forKey:@"KeepOrigin"];
...
[pref synchronize];

//Demonstrate retrieving data

bool yourBool = [pref boolForKey:@"DataIsSecured"];
NSString * yourString = [pref stringForKey:@"KindOfEncrytion"];
...

Advanced usage

  • v1.2.0 available

    • Obfuscate your secret key

      Shouldn’t use this NSString * theSecretKey = @"putYourKeyHere";

      Try this way :point_right: NSString * theSecretKey = @"".p.u.t.Y.o.u.r.K.e.y.H.e.r.e;

    • Store data without encryption

      [pref setObject:@"yourValue" forKey:@"yourKey.nonSecured"];

      Or

      [pref setObject:@"yourValue" forKey:@"yourKey".nonSecured];

    • Migrate data to secured storage

      [NSUserDefaults migrate:[NSUserDefaults standardUserDefaults] to:pref clearSource:YES];

Supported NOTIFICATION Events

  • NOTIFICATION_CANNOT_RETRIEVE_ENCRYPTED_DATA
  • NOTIFICATION_CANNOT_STORE_ENCRYPTED_DATA
  • NOTIFICATION_SECRET_KEY_NOT_SET
  • NOTIFICATION_STORED_DATA_HAS_BEEN_VIOLATED

Supported Encryption Types

Seven Security Layers Solution supports the following property types:

  • NSInteger
  • NSString
  • NSArray
  • string+array
  • NSDictionary
  • NSURL
  • NSData
  • BOOL
  • float
  • double

Contact

Email: [email protected]

Make donation for Hai Kieu's github

Thanks to

MIT License

Dependencies

Dependencies Installation

  1. git:

    $ git clone git://github.com/kelp404/CocoaSecurity.git
    $ cd CocoaSecurity
    $ git submodule update --init
  2. CocoadPods:
    add Podfile in your project path

    platform :ios
    pod 'CocoaSecurity'
    $ pod install

Latest podspec

{
    "name": "NSUserDefaults+SevenSecurityLayers",
    "version": "1.2.0",
    "summary": "Secure your NSUserDefaults just by one line of code. Simple usage / strong encryption protection / maximum productivity",
    "description": "  n* A category which provides an encryption layer for NSUserDefaults to securely save data . n* Using strong AES 356-bit encryptionnn-------------------------------------n####Features: n##### * Secure user data just by one line of code.n###### * Enable to handle exceptional case via built-in NOTIFICATIONn###### * Enable using standardUserDefaults as well as securedUserDefaults parallellynn",
    "homepage": "https://github.com/haikieu/NSUserDefaults-SevenSecurityLayers",
    "screenshots": [
        "https://raw.githubusercontent.com/haikieu/NSUserDefaults-SevenSecurityLayers/master/pictures/usage1.png",
        "https://raw.githubusercontent.com/haikieu/NSUserDefaults-SevenSecurityLayers/master/pictures/usage2.png"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Hai Kieu": "[email protected]"
    },
    "social_media_url": "https://twitter.com/haikieu2907",
    "platforms": {
        "ios": "6.0",
        "osx": "10.7"
    },
    "source": {
        "git": "https://github.com/haikieu/NSUserDefaults-SevenSecurityLayers.git",
        "tag": "1.2.0"
    },
    "source_files": "Classes/*.{h,m}",
    "requires_arc": true,
    "dependencies": {
        "CocoaSecurity": [
            "~> 1.2.1"
        ]
    },
    "frameworks": "Foundation"
}

Pin It on Pinterest

Share This