- Update Pod
This commit is contained in:
1 parent
ef4deb51f6
commit
6a5119dbe3
108 files changed
+13081
-7351
No files matched your search
+19
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2013 No Zebra Network
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Generated
+38
@@ -0,0 +1,38 @@
|
||||
//
|
||||
// NSUserDefaults+AESEncryptor.h
|
||||
// NSUserDefaults-AESEncryptor
|
||||
//
|
||||
// Created by Bruno Tortato Furtado on 08/12/13.
|
||||
// Copyright (c) 2013 No Zebra Network. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSUserDefaults (AESEncryptor)
|
||||
|
||||
- (NSString *)decryptedValueForKey:(NSString *)key;
|
||||
- (void)encryptValue:(NSString *)value withKey:(NSString *)key;
|
||||
|
||||
- (void)removeObjectForAESKey:(NSString *)key;
|
||||
|
||||
- (void)setAESKey:(NSString *)key;
|
||||
- (NSString *)AESKey;
|
||||
|
||||
@end
|
||||
Generated
+89
@@ -0,0 +1,89 @@
|
||||
//
|
||||
// NSUserDefaults+AESEncryptor.m
|
||||
// NSUserDefaults-AESEncryptor
|
||||
//
|
||||
// Created by Bruno Tortato Furtado on 08/12/13.
|
||||
// Copyright (c) 2013 No Zebra Network. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSUserDefaults+AESEncryptor.h"
|
||||
#import "CocoaSecurity.h"
|
||||
|
||||
static NSString * AESKeyString = @"aes key not found";
|
||||
|
||||
@implementation NSUserDefaults (AESEncryptor)
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark - Public methods
|
||||
|
||||
- (NSString *)decryptedValueForKey:(NSString *)key
|
||||
{
|
||||
NSString *encryptedKey = [CocoaSecurity aesEncrypt:key
|
||||
key:[self AESKey]].base64;
|
||||
|
||||
NSString *encryptedValue = [self objectForKey:encryptedKey];
|
||||
|
||||
if (!encryptedValue) {
|
||||
NSLog(@"%s\n\nkey '%@' not found \n\n", __PRETTY_FUNCTION__, key);
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
NSString *value = [CocoaSecurity aesDecryptWithBase64:encryptedValue
|
||||
key:[self AESKey]].utf8String;
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%s\n\n \
|
||||
aesKey: [%@]\n\n \
|
||||
[encrypt_key, encrypt_value]: [%@, %@] \n\n \
|
||||
[key, value]: [%@, %@] \n\n",
|
||||
__PRETTY_FUNCTION__,
|
||||
[self AESKey],
|
||||
encryptedKey, encryptedValue,
|
||||
key, value);
|
||||
#endif
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
- (void)encryptValue:(NSString *)value withKey:(NSString *)key
|
||||
{
|
||||
NSString *encryptedKey = [CocoaSecurity aesEncrypt:key
|
||||
key:[self AESKey]].base64;
|
||||
|
||||
NSString *encryptedValue = [CocoaSecurity aesEncrypt:value
|
||||
key:[self AESKey]].base64;
|
||||
|
||||
[self setObject:encryptedValue forKey:encryptedKey];
|
||||
[self synchronize];
|
||||
|
||||
#ifdef DEBUG
|
||||
NSLog(@"%s\n\n \
|
||||
aesKey: [%@]\n\n \
|
||||
[key, value]: [%@, %@] \n\n \
|
||||
[encrypt_key, encrypt_value]: [%@, %@] \n\n",
|
||||
__PRETTY_FUNCTION__,
|
||||
[self AESKey],
|
||||
key, value,
|
||||
encryptedKey, encryptedValue);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)removeObjectForAESKey:(NSString *)key
|
||||
{
|
||||
NSString *encryptedKey = [CocoaSecurity aesEncrypt:key key:[self AESKey]].base64;
|
||||
[self removeObjectForKey:encryptedKey];
|
||||
[self synchronize];
|
||||
}
|
||||
|
||||
- (void)setAESKey:(NSString *)key
|
||||
{
|
||||
AESKeyString = key;
|
||||
}
|
||||
|
||||
- (NSString *)AESKey
|
||||
{
|
||||
return AESKeyString;
|
||||
}
|
||||
|
||||
@end
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#NSUserDefaults-AESEncryptor 
|
||||
|
||||
NSUserDefaults-AESEncryptor is a NSUserDefaults category. Its purpose to encrypt/decrypt keys and values with AES encryptor.
|
||||
|
||||
[](https://api.travis-ci.org/NZN/NSUserDefaults-AESEncryptor.png)
|
||||
[](http://beta.cocoapods.org/?q=name%3Ansuserdefaults%20name%3Aaesencryptor%2A)
|
||||
[](http://beta.cocoapods.org/?q=name%3Ansuserdefaults%20name%3Aaesencryptor%2A)
|
||||
|
||||
## Requirements
|
||||
|
||||
NSUserDefaults-AESEncryptor works on iOS 5.0+ version and is compatible with ARC projects. It depends on the following Apple frameworks, which should already be included with most Xcode templates:
|
||||
|
||||
* Foundation.framework
|
||||
|
||||
You will need LLVM 3.0 or later in order to build NSUserDefaults-AESEncryptor.
|
||||
|
||||
NSUserDefaults-AESEncryptor uses [CocoaSecurity](https://github.com/kelp404/CocoaSecurity) to encrypt/decrypt.
|
||||
|
||||
## Adding NSUserDefaults-AESEncryptor to your project
|
||||
|
||||
### Cocoapods
|
||||
|
||||
[CocoaPods](http://cocoapods.org) is the recommended way to add `NSUserDefaults-AESEncryptor` to your project.
|
||||
|
||||
* Add a pod entry for NSUserDefaults-AESEncryptor to your Podfile `pod 'NSUserDefaults-AESEncryptor'`
|
||||
* Install the pod(s) by running `pod install`.
|
||||
|
||||
### Source files
|
||||
|
||||
Alternatively you can directly add source files to your project.
|
||||
|
||||
1. Download the [latest code version](https://github.com/NZN/NSUserDefaults-AESEncryptor/archive/master.zip) or add the repository as a git submodule to your git-tracked project.
|
||||
2. Open your project in Xcode, then drag and drop all files at NSUserDefaults-AESEncryptor folder onto your project (use the "Product Navigator view"). Make sure to select Copy items when asked if you extracted the code archive outside of your project.
|
||||
2. Install [CocoaSecurity](https://github.com/kelp404/CocoaSecurity).
|
||||
|
||||
## Usage
|
||||
|
||||
* Import `NSUserDefaults+AESEncryptor.h` and add this to `Prefix.pch`
|
||||
|
||||
```objective-c
|
||||
// Set a key. (If no key is set, a default key will be used)
|
||||
[[NSUserDefaults standardUserDefaults] setAESKey:@"World Cup 2014"];
|
||||
|
||||
// Encrypt
|
||||
[[NSUserDefaults standardUserDefaults] encryptValue:@"Brazil" withKey:@"country"];
|
||||
|
||||
// Decrypt
|
||||
NSString value = [[NSUserDefaults standardUserDefaults] decryptedValueForKey:@"country"];
|
||||
|
||||
// Remove object
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForAESKey:@"country"];
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This code is distributed under the terms and conditions of the [MIT license](LICENSE).
|
||||
|
||||
## Change-log
|
||||
|
||||
A brief summary of each NSUserDefaults-AESEncryptor release can be found on the [wiki](https://github.com/NZN/NSUserDefaults-AESEncryptor/wiki/Change-log).
|
||||
Reference in new issue
Block a user