Merge branch 'dev-OauthMode' into 'develop'

Dev oauth mode

See merge request !35
This commit is contained in:
Giuseppe Nucifora 2017-01-03 11:55:08 +01:00
commit f152085009
905 changed files with 6157 additions and 36925 deletions

View File

@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
2EC5979E315D48625574D725 /* Pods_PNObject_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 808511432137F18DDFE44210 /* Pods_PNObject_Tests.framework */; };
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; };
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58F195388D20070C39A /* CoreGraphics.framework */; };
6003F592195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
@ -21,8 +20,10 @@
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
6003F5BA195388D20070C39A /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 6003F5B8195388D20070C39A /* InfoPlist.strings */; };
6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; };
68119C961E155BAA00E066C7 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 68119C951E155BAA00E066C7 /* Security.framework */; };
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
FD9FF8837F786E50B88531C0 /* Pods_PNObject_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F74BC1D549B9C619883DB7E0 /* Pods_PNObject_Example.framework */; };
BCF991672BE36A8FE7F43A6B /* libPods-PNObject_Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E7FCF35EF87A5BDD07CA6CD2 /* libPods-PNObject_Tests.a */; };
C52729592D50CEDEC002ADC9 /* libPods-PNObject_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0ABF8340F735722CEE937FA3 /* libPods-PNObject_Example.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -36,6 +37,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
0ABF8340F735722CEE937FA3 /* libPods-PNObject_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PNObject_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
116AF818F8117B91EF290C9A /* Pods-PNObject_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PNObject_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-PNObject_Example/Pods-PNObject_Example.release.xcconfig"; sourceTree = "<group>"; };
2661CEE1F223361CD1DACC25 /* PNObject.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = PNObject.podspec; path = ../PNObject.podspec; sourceTree = "<group>"; };
3E392C278361604C1602CAF0 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
@ -58,13 +60,13 @@
6003F5B9195388D20070C39A /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
6003F5BB195388D20070C39A /* Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Tests.m; sourceTree = "<group>"; };
606FC2411953D9B200FFA9A0 /* Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Tests-Prefix.pch"; sourceTree = "<group>"; };
808511432137F18DDFE44210 /* Pods_PNObject_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PNObject_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
68119C951E155BAA00E066C7 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
A90E0E5930707E3F83662328 /* Pods-PNObject_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PNObject_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PNObject_Tests/Pods-PNObject_Tests.debug.xcconfig"; sourceTree = "<group>"; };
C0F786F6B0C2234E3B3A5F30 /* Pods-PNObject_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PNObject_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-PNObject_Tests/Pods-PNObject_Tests.release.xcconfig"; sourceTree = "<group>"; };
C6D958A9E3E6FFB7818A72C7 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
E20844B85780704FB196FA2A /* Pods-PNObject_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PNObject_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PNObject_Example/Pods-PNObject_Example.debug.xcconfig"; sourceTree = "<group>"; };
F74BC1D549B9C619883DB7E0 /* Pods_PNObject_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PNObject_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E7FCF35EF87A5BDD07CA6CD2 /* libPods-PNObject_Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-PNObject_Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -72,10 +74,11 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
68119C961E155BAA00E066C7 /* Security.framework in Frameworks */,
6003F590195388D20070C39A /* CoreGraphics.framework in Frameworks */,
6003F592195388D20070C39A /* UIKit.framework in Frameworks */,
6003F58E195388D20070C39A /* Foundation.framework in Frameworks */,
FD9FF8837F786E50B88531C0 /* Pods_PNObject_Example.framework in Frameworks */,
C52729592D50CEDEC002ADC9 /* libPods-PNObject_Example.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -86,7 +89,7 @@
6003F5B0195388D20070C39A /* XCTest.framework in Frameworks */,
6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */,
6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */,
2EC5979E315D48625574D725 /* Pods_PNObject_Tests.framework in Frameworks */,
BCF991672BE36A8FE7F43A6B /* libPods-PNObject_Tests.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -117,12 +120,13 @@
6003F58C195388D20070C39A /* Frameworks */ = {
isa = PBXGroup;
children = (
68119C951E155BAA00E066C7 /* Security.framework */,
6003F58D195388D20070C39A /* Foundation.framework */,
6003F58F195388D20070C39A /* CoreGraphics.framework */,
6003F591195388D20070C39A /* UIKit.framework */,
6003F5AF195388D20070C39A /* XCTest.framework */,
F74BC1D549B9C619883DB7E0 /* Pods_PNObject_Example.framework */,
808511432137F18DDFE44210 /* Pods_PNObject_Tests.framework */,
0ABF8340F735722CEE937FA3 /* libPods-PNObject_Example.a */,
E7FCF35EF87A5BDD07CA6CD2 /* libPods-PNObject_Tests.a */,
);
name = Frameworks;
sourceTree = "<group>";
@ -244,7 +248,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = PNObj;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Giuseppe Nucifora";
TargetAttributes = {
6003F589195388D20070C39A = {
@ -450,20 +454,24 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
@ -490,13 +498,18 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0820"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -31,7 +31,7 @@
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
/*
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://packman.local/app_dev.php/api/v1/",
EnvironmentStage : @"https://packman.ppreview.it/app_stage.php/api/v1/",
EnvironmentProduction : @"http://packman.ppreview.it/app_stage.php/api/v1/"
@ -40,7 +40,20 @@
[[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentProduction];
#ifdef DEBUG
[[PNObjectConfig sharedInstance] setEnvironment:EnvironmentStage];
#endif
#endif*/
[PNObjectConfig initSharedInstanceForEnvironments:@{EnvironmentDevelopment : @"http://bmwcallingweb.local/app_dev.php/api/v1/",
EnvironmentStage : @"http://bmwcallingweb.ppreview.it/app_dev.php/api/v1/",
EnvironmentProduction : @"http://bmwcallingweb.ppreview.it/app_dev.php/api/v1/"
} userSubclass:[PNUser class] withOauthMode:OAuthModePassword];
[[PNObjectConfig sharedInstance] setClientID:@"1_pqjo2w5k7j4g8skco408oc048w8so0ws840gcg8k8gwsgk0g4" clientSecret:@"10w0vg2v6eggooc4wks4w4s0wkwok0wkck0w888so0o80g88w8" forEnv:EnvironmentStage];
[[PNObjectConfig sharedInstance] setOauthUserName:@"admin" oauthPassword:@"admin" forEnv:EnvironmentStage];
//[[PNObjectConfig sharedInstance] setHTTPHeaderValue:@"XMLHttpRequest" forKey:@"X-Request-With"];

View File

@ -150,14 +150,14 @@
}];*/
[PNUser socialUserFromViewController:self blockSuccess:^(PNUser * _Nullable responseObject) {
/*[PNUser socialUserFromViewController:self blockSuccess:^(PNUser * _Nullable responseObject) {
NSLog(@"%@",[[PNUser currentUser] JSONFormObject]);
} failure:^(NSError * _Nonnull error) {
}];
}];*/

View File

@ -1,5 +1,3 @@
use_frameworks!
target 'PNObject_Example' do
pod 'PNObject', :path => '../'
pod 'PureLayout'

View File

@ -20,7 +20,6 @@ PODS:
- Bolts/AppLinks (1.8.4):
- Bolts/Tasks
- Bolts/Tasks (1.8.4)
- CocoaSecurity (1.2.4)
- CodFis-Helper (0.1.3)
- DDDKeychainWrapper (1.0.0)
- DJLocalization (1.2.2):
@ -33,16 +32,12 @@ PODS:
- FBSDKCoreKit
- FBSDKShareKit (4.18.0):
- FBSDKCoreKit
- libsodium (1.0.11)
- NAChloride (2.2.1):
- libsodium
- NSDataAES (0.2.2)
- NSDate_Utils (1.0.0)
- NSString-Helper (1.0.5)
- NSUserDefaults-AESEncryptor (0.0.4):
- CocoaSecurity (~> 1.2.2)
- nv-ios-http-status (0.0.1)
- PEAR-FileManager-iOS (1.3.1)
- PNObject (1.0.0):
- PNObject (1.0.2):
- AFNetworking
- CodFis-Helper
- DDDKeychainWrapper
@ -50,10 +45,9 @@ PODS:
- FBSDKCoreKit
- FBSDKLoginKit
- FBSDKShareKit
- NAChloride
- NSDataAES
- NSDate_Utils
- NSString-Helper
- NSUserDefaults-AESEncryptor
- nv-ios-http-status
- PEAR-FileManager-iOS
- RZDataBinding
@ -78,7 +72,6 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67
Bolts: 8a7995239dbe724f9cba2248b766d48b7ebdd322
CocoaSecurity: d288a6f87e0f363823d2cb83e753814a6944f71a
CodFis-Helper: 28be4c74d7202542459d72354f59b1215871de87
DDDKeychainWrapper: e681a4daba6448786fa83b4941f58102a33b1897
DJLocalization: 0c84029af375647d4104a42ae36be87194c46c47
@ -86,20 +79,18 @@ SPEC CHECKSUMS:
FBSDKCoreKit: 15fef8804a4629f98c6f4e55e81a76c9d725d85e
FBSDKLoginKit: 6773073e970b2b15fb12e451ce7f11da0532b880
FBSDKShareKit: 0b8d6cc3f103c75297eb3c62caec284a2ccf1b9e
libsodium: 9aba161d2ee096977ecbdcce1ada69ffe511970c
NAChloride: 8f3d4f9a20df6b68840789a22a70aa4fcc437b0c
NSDataAES: 967ea3337476a80e9838a533c25d570a06855ed0
NSDate_Utils: 45d47afab329001ccafe056308d0cc05460e5298
NSString-Helper: 459e1b6a62b3bf7db10f01b0d102548608e945c4
NSUserDefaults-AESEncryptor: da02cfef056f1e18ebe2748767915f08b274c9c5
nv-ios-http-status: b6c2b5fc8656cc19e0d3000dadce2080b99d0e2f
PEAR-FileManager-iOS: 3bc403f68a53483f5629aa822f4649e40275c4d3
PNObject: 34839792d6fcc437b3123d0770b4d45e845bf2c9
PNObject: 21a29c6dae126f2b98e670f4c64d985b179ee097
PureLayout: 4d550abe49a94f24c2808b9b95db9131685fe4cd
RZDataBinding: 6981e90ddaae2f5e02028323b1043f8c31013109
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
StrongestPasswordValidator: 921e42615bdf353513c6f925bffd4fc29865dbd7
UIDevice-Utils: 11c10b18d3c6489b45a97436e5ae6064a3622820
PODFILE CHECKSUM: 57090c7ea88a91b49ca8dd73d9e7c6b866e772ba
PODFILE CHECKSUM: db08ccdd0a68e33d4a1cceb1843643fbab2f2a8e
COCOAPODS: 1.2.0.beta.1
COCOAPODS: 1.2.0.beta.3

View File

@ -1,85 +0,0 @@
/*
CocoaSecurity 1.1
Created by Kelp on 12/5/12.
Copyright (c) 2012 Kelp http://kelp.phate.org/
MIT License
CocoaSecurity is core. It provides AES encrypt, AES decrypt, Hash(MD5, HmacMD5, SHA1~SHA512, HmacSHA1~HmacSHA512) messages.
*/
#import <Foundation/Foundation.h>
#import <Foundation/NSException.h>
#pragma mark - CocoaSecurityResult
@interface CocoaSecurityResult : NSObject
@property (strong, nonatomic, readonly) NSData *data;
@property (strong, nonatomic, readonly) NSString *utf8String;
@property (strong, nonatomic, readonly) NSString *hex;
@property (strong, nonatomic, readonly) NSString *hexLower;
@property (strong, nonatomic, readonly) NSString *base64;
- (id)initWithBytes:(unsigned char[])initData length:(NSUInteger)length;
@end
#pragma mark - CocoaSecurity
@interface CocoaSecurity : NSObject
#pragma mark - AES Encrypt
+ (CocoaSecurityResult *)aesEncrypt:(NSString *)data key:(NSString *)key;
+ (CocoaSecurityResult *)aesEncrypt:(NSString *)data hexKey:(NSString *)key hexIv:(NSString *)iv;
+ (CocoaSecurityResult *)aesEncrypt:(NSString *)data key:(NSData *)key iv:(NSData *)iv;
+ (CocoaSecurityResult *)aesEncryptWithData:(NSData *)data key:(NSData *)key iv:(NSData *)iv;
#pragma mark AES Decrypt
+ (CocoaSecurityResult *)aesDecryptWithBase64:(NSString *)data key:(NSString *)key;
+ (CocoaSecurityResult *)aesDecryptWithBase64:(NSString *)data hexKey:(NSString *)key hexIv:(NSString *)iv;
+ (CocoaSecurityResult *)aesDecryptWithBase64:(NSString *)data key:(NSData *)key iv:(NSData *)iv;
+ (CocoaSecurityResult *)aesDecryptWithData:(NSData *)data key:(NSData *)key iv:(NSData *)iv;
#pragma mark - MD5
+ (CocoaSecurityResult *)md5:(NSString *)hashString;
+ (CocoaSecurityResult *)md5WithData:(NSData *)hashData;
#pragma mark HMAC-MD5
+ (CocoaSecurityResult *)hmacMd5:(NSString *)hashString hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacMd5WithData:(NSData *)hashData hmacKey:(NSString *)key;
#pragma mark - SHA
+ (CocoaSecurityResult *)sha1:(NSString *)hashString;
+ (CocoaSecurityResult *)sha1WithData:(NSData *)hashData;
+ (CocoaSecurityResult *)sha224:(NSString *)hashString;
+ (CocoaSecurityResult *)sha224WithData:(NSData *)hashData;
+ (CocoaSecurityResult *)sha256:(NSString *)hashString;
+ (CocoaSecurityResult *)sha256WithData:(NSData *)hashData;
+ (CocoaSecurityResult *)sha384:(NSString *)hashString;
+ (CocoaSecurityResult *)sha384WithData:(NSData *)hashData;
+ (CocoaSecurityResult *)sha512:(NSString *)hashString;
+ (CocoaSecurityResult *)sha512WithData:(NSData *)hashData;
#pragma mark HMAC-SHA
+ (CocoaSecurityResult *)hmacSha1:(NSString *)hashString hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha1WithData:(NSData *)hashData hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha224:(NSString *)hashString hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha224WithData:(NSData *)hashData hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha256:(NSString *)hashString hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha256WithData:(NSData *)hashData hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha384:(NSString *)hashString hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha384WithData:(NSData *)hashData hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha512:(NSString *)hashString hmacKey:(NSString *)key;
+ (CocoaSecurityResult *)hmacSha512WithData:(NSData *)hashData hmacKey:(NSString *)key;
@end
#pragma mark - CocoaSecurityEncoder
@interface CocoaSecurityEncoder : NSObject
- (NSString *)base64:(NSData *)data;
- (NSString *)hex:(NSData *)data useLower:(BOOL)isOutputLower;
@end
#pragma mark - CocoaSecurityDecoder
@interface CocoaSecurityDecoder : NSObject
- (NSData *)base64:(NSString *)data;
- (NSData *)hex:(NSString *)data;
@end

View File

@ -1,508 +0,0 @@
//
// CocoaSecurity.m
//
// Created by Kelp on 12/5/12.
// Copyright (c) 2012 Kelp http://kelp.phate.org/
// MIT License
//
#import "CocoaSecurity.h"
#import <CommonCrypto/CommonHMAC.h>
#import <CommonCrypto/CommonCryptor.h>
#import "Base64.h"
#pragma mark - CocoaSecurity
@implementation CocoaSecurity
#pragma mark - AES Encrypt
// default AES Encrypt, key -> SHA384(key).sub(0, 32), iv -> SHA384(key).sub(32, 16)
+ (CocoaSecurityResult *)aesEncrypt:(NSString *)data key:(NSString *)key
{
CocoaSecurityResult * sha = [self sha384:key];
NSData *aesKey = [sha.data subdataWithRange:NSMakeRange(0, 32)];
NSData *aesIv = [sha.data subdataWithRange:NSMakeRange(32, 16)];
return [self aesEncrypt:data key:aesKey iv:aesIv];
}
#pragma mark AES Encrypt 128, 192, 256
+ (CocoaSecurityResult *)aesEncrypt:(NSString *)data hexKey:(NSString *)key hexIv:(NSString *)iv
{
CocoaSecurityDecoder *decoder = [CocoaSecurityDecoder new];
NSData *aesKey = [decoder hex:key];
NSData *aesIv = [decoder hex:iv];
return [self aesEncrypt:data key:aesKey iv:aesIv];
}
+ (CocoaSecurityResult *)aesEncrypt:(NSString *)data key:(NSData *)key iv:(NSData *)iv
{
return [self aesEncryptWithData:[data dataUsingEncoding:NSUTF8StringEncoding] key:key iv:iv];
}
+ (CocoaSecurityResult *)aesEncryptWithData:(NSData *)data key:(NSData *)key iv:(NSData *)iv
{
// check length of key and iv
if ([iv length] != 16) {
@throw [NSException exceptionWithName:@"Cocoa Security"
reason:@"Length of iv is wrong. Length of iv should be 16(128bits)"
userInfo:nil];
}
if ([key length] != 16 && [key length] != 24 && [key length] != 32 ) {
@throw [NSException exceptionWithName:@"Cocoa Security"
reason:@"Length of key is wrong. Length of iv should be 16, 24 or 32(128, 192 or 256bits)"
userInfo:nil];
}
// setup output buffer
size_t bufferSize = [data length] + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
// do encrypt
size_t encryptedSize = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
kCCAlgorithmAES128,
kCCOptionPKCS7Padding,
[key bytes], // Key
[key length], // kCCKeySizeAES
[iv bytes], // IV
[data bytes],
[data length],
buffer,
bufferSize,
&encryptedSize);
if (cryptStatus == kCCSuccess) {
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:buffer length:encryptedSize];
free(buffer);
return result;
}
else {
free(buffer);
@throw [NSException exceptionWithName:@"Cocoa Security"
reason:@"Encrypt Error!"
userInfo:nil];
return nil;
}
}
#pragma mark - AES Decrypt
// default AES Decrypt, key -> SHA384(key).sub(0, 32), iv -> SHA384(key).sub(32, 16)
+ (CocoaSecurityResult *)aesDecryptWithBase64:(NSString *)data key:(NSString *)key
{
CocoaSecurityResult * sha = [self sha384:key];
NSData *aesKey = [sha.data subdataWithRange:NSMakeRange(0, 32)];
NSData *aesIv = [sha.data subdataWithRange:NSMakeRange(32, 16)];
return [self aesDecryptWithBase64:data key:aesKey iv:aesIv];
}
#pragma mark AES Decrypt 128, 192, 256
+ (CocoaSecurityResult *)aesDecryptWithBase64:(NSString *)data hexKey:(NSString *)key hexIv:(NSString *)iv
{
CocoaSecurityDecoder *decoder = [CocoaSecurityDecoder new];
NSData *aesKey = [decoder hex:key];
NSData *aesIv = [decoder hex:iv];
return [self aesDecryptWithBase64:data key:aesKey iv:aesIv];
}
+ (CocoaSecurityResult *)aesDecryptWithBase64:(NSString *)data key:(NSData *)key iv:(NSData *)iv
{
CocoaSecurityDecoder *decoder = [CocoaSecurityDecoder new];
return [self aesDecryptWithData:[decoder base64:data] key:key iv:iv];
}
+ (CocoaSecurityResult *)aesDecryptWithData:(NSData *)data key:(NSData *)key iv:(NSData *)iv
{
// check length of key and iv
if ([iv length] != 16) {
@throw [NSException exceptionWithName:@"Cocoa Security"
reason:@"Length of iv is wrong. Length of iv should be 16(128bits)"
userInfo:nil];
}
if ([key length] != 16 && [key length] != 24 && [key length] != 32 ) {
@throw [NSException exceptionWithName:@"Cocoa Security"
reason:@"Length of key is wrong. Length of iv should be 16, 24 or 32(128, 192 or 256bits)"
userInfo:nil];
}
// setup output buffer
size_t bufferSize = [data length] + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
// do encrypt
size_t encryptedSize = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt,
kCCAlgorithmAES128,
kCCOptionPKCS7Padding,
[key bytes], // Key
[key length], // kCCKeySizeAES
[iv bytes], // IV
[data bytes],
[data length],
buffer,
bufferSize,
&encryptedSize);
if (cryptStatus == kCCSuccess) {
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:buffer length:encryptedSize];
free(buffer);
return result;
}
else {
free(buffer);
@throw [NSException exceptionWithName:@"Cocoa Security"
reason:@"Decrypt Error!"
userInfo:nil];
return nil;
}
}
#pragma mark - MD5
+ (CocoaSecurityResult *)md5:(NSString *)hashString
{
return [self md5WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding]];
}
+ (CocoaSecurityResult *)md5WithData:(NSData *)hashData
{
unsigned char *digest;
digest = malloc(CC_MD5_DIGEST_LENGTH);
CC_MD5([hashData bytes], (CC_LONG)[hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_MD5_DIGEST_LENGTH];
free(digest);
return result;
}
#pragma mark - HMAC-MD5
+ (CocoaSecurityResult *)hmacMd5:(NSString *)hashString hmacKey:(NSString *)key
{
return [self hmacMd5WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding] hmacKey:key];
}
+ (CocoaSecurityResult *)hmacMd5WithData:(NSData *)hashData hmacKey:(NSString *)key
{
unsigned char *digest;
digest = malloc(CC_MD5_DIGEST_LENGTH);
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
CCHmac(kCCHmacAlgMD5, cKey, strlen(cKey), [hashData bytes], [hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_MD5_DIGEST_LENGTH];
free(digest);
cKey = nil;
return result;
}
#pragma mark - SHA1
+ (CocoaSecurityResult *)sha1:(NSString *)hashString
{
return [self sha1WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding]];
}
+ (CocoaSecurityResult *)sha1WithData:(NSData *)hashData
{
unsigned char *digest;
digest = malloc(CC_SHA1_DIGEST_LENGTH);
CC_SHA1([hashData bytes], (CC_LONG)[hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
free(digest);
return result;
}
#pragma mark SHA224
+ (CocoaSecurityResult *)sha224:(NSString *)hashString
{
return [self sha224WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding]];
}
+ (CocoaSecurityResult *)sha224WithData:(NSData *)hashData
{
unsigned char *digest;
digest = malloc(CC_SHA224_DIGEST_LENGTH);
CC_SHA224([hashData bytes], (CC_LONG)[hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA224_DIGEST_LENGTH];
free(digest);
return result;
}
#pragma mark SHA256
+ (CocoaSecurityResult *)sha256:(NSString *)hashString
{
return [self sha256WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding]];
}
+ (CocoaSecurityResult *)sha256WithData:(NSData *)hashData
{
unsigned char *digest;
digest = malloc(CC_SHA256_DIGEST_LENGTH);
CC_SHA256([hashData bytes], (CC_LONG)[hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA256_DIGEST_LENGTH];
free(digest);
return result;
}
#pragma mark SHA384
+ (CocoaSecurityResult *)sha384:(NSString *)hashString
{
return [self sha384WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding]];
}
+ (CocoaSecurityResult *)sha384WithData:(NSData *)hashData
{
unsigned char *digest;
digest = malloc(CC_SHA384_DIGEST_LENGTH);
CC_SHA384([hashData bytes], (CC_LONG)[hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA384_DIGEST_LENGTH];
free(digest);
return result;
}
#pragma mark SHA512
+ (CocoaSecurityResult *)sha512:(NSString *)hashString
{
return [self sha512WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding]];
}
+ (CocoaSecurityResult *)sha512WithData:(NSData *)hashData
{
unsigned char *digest;
digest = malloc(CC_SHA512_DIGEST_LENGTH);
CC_SHA512([hashData bytes], (CC_LONG)[hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA512_DIGEST_LENGTH];
free(digest);
return result;
}
#pragma mark - HMAC-SHA1
+ (CocoaSecurityResult *)hmacSha1:(NSString *)hashString hmacKey:(NSString *)key
{
return [self hmacSha1WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding] hmacKey:key];
}
+ (CocoaSecurityResult *)hmacSha1WithData:(NSData *)hashData hmacKey:(NSString *)key
{
unsigned char *digest;
digest = malloc(CC_SHA1_DIGEST_LENGTH);
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), [hashData bytes], [hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
free(digest);
cKey = nil;
return result;
}
#pragma mark HMAC-SHA224
+ (CocoaSecurityResult *)hmacSha224:(NSString *)hashString hmacKey:(NSString *)key
{
return [self hmacSha224WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding] hmacKey:key];
}
+ (CocoaSecurityResult *)hmacSha224WithData:(NSData *)hashData hmacKey:(NSString *)key
{
unsigned char *digest;
digest = malloc(CC_SHA224_DIGEST_LENGTH);
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
CCHmac(kCCHmacAlgSHA224, cKey, strlen(cKey), [hashData bytes], [hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA224_DIGEST_LENGTH];
free(digest);
cKey = nil;
return result;
}
#pragma mark HMAC-SHA256
+ (CocoaSecurityResult *)hmacSha256:(NSString *)hashString hmacKey:(NSString *)key
{
return [self hmacSha256WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding] hmacKey:key];
}
+ (CocoaSecurityResult *)hmacSha256WithData:(NSData *)hashData hmacKey:(NSString *)key
{
unsigned char *digest;
digest = malloc(CC_SHA256_DIGEST_LENGTH);
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), [hashData bytes], [hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA256_DIGEST_LENGTH];
free(digest);
cKey = nil;
return result;
}
#pragma mark HMAC-SHA384
+ (CocoaSecurityResult *)hmacSha384:(NSString *)hashString hmacKey:(NSString *)key
{
return [self hmacSha384WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding] hmacKey:key];
}
+ (CocoaSecurityResult *)hmacSha384WithData:(NSData *)hashData hmacKey:(NSString *)key
{
unsigned char *digest;
digest = malloc(CC_SHA384_DIGEST_LENGTH);
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
CCHmac(kCCHmacAlgSHA384, cKey, strlen(cKey), [hashData bytes], [hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA384_DIGEST_LENGTH];
free(digest);
cKey = nil;
return result;
}
#pragma mark HMAC-SHA512
+ (CocoaSecurityResult *)hmacSha512:(NSString *)hashString hmacKey:(NSString *)key
{
return [self hmacSha512WithData:[hashString dataUsingEncoding:NSUTF8StringEncoding] hmacKey:key];
}
+ (CocoaSecurityResult *)hmacSha512WithData:(NSData *)hashData hmacKey:(NSString *)key
{
unsigned char *digest;
digest = malloc(CC_SHA512_DIGEST_LENGTH);
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
CCHmac(kCCHmacAlgSHA512, cKey, strlen(cKey), [hashData bytes], [hashData length], digest);
CocoaSecurityResult *result = [[CocoaSecurityResult alloc] initWithBytes:digest length:CC_SHA512_DIGEST_LENGTH];
free(digest);
cKey = nil;
return result;
}
@end
#pragma mark - CocoaSecurityResult
@implementation CocoaSecurityResult
@synthesize data = _data;
#pragma mark - Init
- (id)initWithBytes:(unsigned char[])initData length:(NSUInteger)length
{
self = [super init];
if (self) {
_data = [NSData dataWithBytes:initData length:length];
}
return self;
}
#pragma mark UTF8 String
// convert CocoaSecurityResult to UTF8 string
- (NSString *)utf8String
{
NSString *result = [[NSString alloc] initWithData:_data encoding:NSUTF8StringEncoding];
return result;
}
#pragma mark HEX
// convert CocoaSecurityResult to HEX string
- (NSString *)hex
{
CocoaSecurityEncoder *encoder = [CocoaSecurityEncoder new];
return [encoder hex:_data useLower:false];
}
- (NSString *)hexLower
{
CocoaSecurityEncoder *encoder = [CocoaSecurityEncoder new];
return [encoder hex:_data useLower:true];
}
#pragma mark Base64
// convert CocoaSecurityResult to Base64 string
- (NSString *)base64
{
CocoaSecurityEncoder *encoder = [CocoaSecurityEncoder new];
return [encoder base64:_data];
}
@end
#pragma mark - CocoaSecurityEncoder
@implementation CocoaSecurityEncoder
// convert NSData to Base64
- (NSString *)base64:(NSData *)data
{
return [data base64EncodedString];
}
// convert NSData to hex string
- (NSString *)hex:(NSData *)data useLower:(BOOL)isOutputLower
{
if (data.length == 0) { return nil; }
static const char HexEncodeCharsLower[] = "0123456789abcdef";
static const char HexEncodeChars[] = "0123456789ABCDEF";
char *resultData;
// malloc result data
resultData = malloc([data length] * 2 +1);
// convert imgData(NSData) to char[]
unsigned char *sourceData = ((unsigned char *)[data bytes]);
NSUInteger length = [data length];
if (isOutputLower) {
for (NSUInteger index = 0; index < length; index++) {
// set result data
resultData[index * 2] = HexEncodeCharsLower[(sourceData[index] >> 4)];
resultData[index * 2 + 1] = HexEncodeCharsLower[(sourceData[index] % 0x10)];
}
}
else {
for (NSUInteger index = 0; index < length; index++) {
// set result data
resultData[index * 2] = HexEncodeChars[(sourceData[index] >> 4)];
resultData[index * 2 + 1] = HexEncodeChars[(sourceData[index] % 0x10)];
}
}
resultData[[data length] * 2] = 0;
// convert result(char[]) to NSString
NSString *result = [NSString stringWithCString:resultData encoding:NSASCIIStringEncoding];
sourceData = nil;
free(resultData);
return result;
}
@end
#pragma mark - CocoaSecurityDecoder
@implementation CocoaSecurityDecoder
- (NSData *)base64:(NSString *)string
{
return [NSData dataWithBase64EncodedString:string];
}
- (NSData *)hex:(NSString *)data
{
if (data.length == 0) { return nil; }
static const unsigned char HexDecodeChars[] =
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, //49
2, 3, 4, 5, 6, 7, 8, 9, 0, 0, //59
0, 0, 0, 0, 0, 10, 11, 12, 13, 14,
15, 0, 0, 0, 0, 0, 0, 0, 0, 0, //79
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 10, 11, 12, //99
13, 14, 15
};
// convert data(NSString) to CString
const char *source = [data cStringUsingEncoding:NSUTF8StringEncoding];
// malloc buffer
unsigned char *buffer;
NSUInteger length = strlen(source) / 2;
buffer = malloc(length);
for (NSUInteger index = 0; index < length; index++) {
buffer[index] = (HexDecodeChars[source[index * 2]] << 4) + (HexDecodeChars[source[index * 2 + 1]]);
}
// init result NSData
NSData *result = [NSData dataWithBytes:buffer length:length];
free(buffer);
source = nil;
return result;
}
@end

View File

@ -1,8 +0,0 @@
The MIT License (MIT)
Copyright (c) 2013 Kelp https://github.com/kelp404
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.

View File

@ -1,111 +0,0 @@
#CocoaSecurity [![Build Status](https://secure.travis-ci.org/kelp404/CocoaSecurity.png?branch=master)](http://travis-ci.org/#!/kelp404/CocoaSecurity)
Kelp https://twitter.com/kelp404/
[MIT License][mit]
[MIT]: http://www.opensource.org/licenses/mit-license.php
CocoaSecurity include 4 classes, `CocoaSecurity`, `CocoaSecurityResult`, `CocoaSecurityEncoder` and `CocoaSecurityDecoder`.
##CocoaSecurity
CocoaSecurity is core. It provides AES encrypt, AES decrypt, Hash(MD5, HmacMD5, SHA1~SHA512, HmacSHA1~HmacSHA512) messages.
**MD5:**
```objective-c
CocoaSecurityResult *md5 = [CocoaSecurity md5:@"kelp"];
// md5.hex = 'C40C69779E15780ADAE46C45EB451E23'
// md5.hexLower = 'c40c69779e15780adae46c45eb451e23'
// md5.base64 = 'xAxpd54VeAra5GxF60UeIw=='
```
**SHA256:**
```objective-c
CocoaSecurityResult *sha256 = [CocoaSecurity sha256:@"kelp"];
// sha256.hexLower = '280f8bb8c43d532f389ef0e2a5321220b0782b065205dcdfcb8d8f02ed5115b9'
// sha256.base64 = 'KA+LuMQ9Uy84nvDipTISILB4KwZSBdzfy42PAu1RFbk='
```
**default AES Encrypt:**<br/>
key -> SHA384(key).sub(0, 32)<br/>
iv -> SHA384(key).sub(32, 16)
```objective-c
CocoaSecurityResult *aesDefault = [CocoaSecurity aesEncrypt:@"kelp" key:@"key"];
// aesDefault.base64 = 'ez9uubPneV1d2+rpjnabJw=='
```
**AES256 Encrypt & Decrypt:**
```objective-c
CocoaSecurityResult *aes256 = [CocoaSecurity aesEncrypt:@"kelp"
hexKey:@"280f8bb8c43d532f389ef0e2a5321220b0782b065205dcdfcb8d8f02ed5115b9"
hexIv:@"CC0A69779E15780ADAE46C45EB451A23"];
// aes256.base64 = 'WQYg5qvcGyCBY3IF0hPsoQ=='
CocoaSecurityResult *aes256Decrypt = [CocoaSecurity aesDecryptWithBase64:@"WQYg5qvcGyCBY3IF0hPsoQ=="
hexKey:@"280f8bb8c43d532f389ef0e2a5321220b0782b065205dcdfcb8d8f02ed5115b9"
hexIv:@"CC0A69779E15780ADAE46C45EB451A23"];
// aes256Decrypt.utf8String = 'kelp'
```
##CocoaSecurityResult
CocoaSecurityResult is the result class of CocoaSecurity. It provides convert result data to NSData, NSString, HEX string, Base64 string.
```objective-c
@property (strong, nonatomic, readonly) NSData *data;
@property (strong, nonatomic, readonly) NSString *utf8String;
@property (strong, nonatomic, readonly) NSString *hex;
@property (strong, nonatomic, readonly) NSString *hexLower;
@property (strong, nonatomic, readonly) NSString *base64;
```
##CocoaSecurityEncoder
CocoaSecurityEncoder provides convert NSData to HEX string, Base64 string.
```objective-c
- (NSString *)base64:(NSData *)data;
- (NSString *)hex:(NSData *)data useLower:(BOOL)isOutputLower;
```
**example:**
```objective-c
CocoaSecurityEncoder *encoder = [CocoaSecurityEncoder new];
NSString *str1 = [encoder hex:[@"kelp" dataUsingEncoding:NSUTF8StringEncoding] useLower:NO];
// str1 = '6B656C70'
NSString *str2 = [encoder base64:[@"kelp" dataUsingEncoding:NSUTF8StringEncoding]];
// str2 = 'a2VscA=='
```
##CocoaSecurityDecoder
CocoaSecurityEncoder provides convert HEX string or Base64 string to NSData.
```objective-c
- (NSData *)base64:(NSString *)data;
- (NSData *)hex:(NSString *)data;
```
**example:**
```objective-c
CocoaSecurityDecoder *decoder = [CocoaSecurityDecoder new];
NSData *data1 = [decoder hex:@"CC0A69779E15780ADAE46C45EB451A23"];
// data1 = <cc0a6977 9e15780a dae46c45 eb451a23>
NSData *data2 = [decoder base64:@"zT1PS64MnXIUDCUiy13RRg=="];
// data2 = <cd3d4f4b ae0c9d72 140c2522 cb5dd146>
```
##Installation
1. **git:**
```
$ git clone git://github.com/kelp404/CocoaSecurity.git
$ cd CocoaSecurity
$ git submodule update --init
```
2. **<a href="http://cocoapods.org/?q=CocoaSecurity" target="_blank">CocoadPods</a>:**
add `Podfile` in your project path
```
platform :ios
pod 'CocoaSecurity'
```
```
$ pod install
```

View File

@ -1,53 +0,0 @@
//
// Base64.h
//
// Version 1.2
//
// Created by Nick Lockwood on 12/01/2012.
// Copyright (C) 2012 Charcoal Design
//
// Distributed under the permissive zlib License
// Get the latest version from here:
//
// https://github.com/nicklockwood/Base64
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
#import <Foundation/Foundation.h>
@interface NSData (Base64)
+ (NSData *)dataWithBase64EncodedString:(NSString *)string;
- (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth;
- (NSString *)base64EncodedString;
@end
@interface NSString (Base64)
+ (NSString *)stringWithBase64EncodedString:(NSString *)string;
- (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth;
- (NSString *)base64EncodedString;
- (NSString *)base64DecodedString;
- (NSData *)base64DecodedData;
@end

View File

@ -1,167 +0,0 @@
//
// Base64.m
//
// Version 1.2
//
// Created by Nick Lockwood on 12/01/2012.
// Copyright (C) 2012 Charcoal Design
//
// Distributed under the permissive zlib License
// Get the latest version from here:
//
// https://github.com/nicklockwood/Base64
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an aacknowledgment in the product documentation would be
// appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
#import "Base64.h"
#pragma GCC diagnostic ignored "-Wselector"
#import <Availability.h>
#if !__has_feature(objc_arc)
#error This library requires automatic reference counting
#endif
@implementation NSData (Base64)
+ (NSData *)dataWithBase64EncodedString:(NSString *)string
{
if (![string length]) return nil;
NSData *decoded = nil;
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9 || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
if (![NSData instancesRespondToSelector:@selector(initWithBase64EncodedString:options:)])
{
decoded = [[self alloc] initWithBase64Encoding:[string stringByReplacingOccurrencesOfString:@"[^A-Za-z0-9+/=]" withString:@"" options:NSRegularExpressionSearch range:NSMakeRange(0, [string length])]];
}
else
#endif
{
decoded = [[self alloc] initWithBase64EncodedString:string options:NSDataBase64DecodingIgnoreUnknownCharacters];
}
return [decoded length]? decoded: nil;
}
- (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth
{
if (![self length]) return nil;
NSString *encoded = nil;
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9 || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
if (![NSData instancesRespondToSelector:@selector(base64EncodedStringWithOptions:)])
{
encoded = [self base64Encoding];
}
else
#endif
{
switch (wrapWidth)
{
case 64:
{
return [self base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
}
case 76:
{
return [self base64EncodedStringWithOptions:NSDataBase64Encoding76CharacterLineLength];
}
default:
{
encoded = [self base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0];
}
}
}
if (!wrapWidth || wrapWidth >= [encoded length])
{
return encoded;
}
wrapWidth = (wrapWidth / 4) * 4;
NSMutableString *result = [NSMutableString string];
for (NSUInteger i = 0; i < [encoded length]; i+= wrapWidth)
{
if (i + wrapWidth >= [encoded length])
{
[result appendString:[encoded substringFromIndex:i]];
break;
}
[result appendString:[encoded substringWithRange:NSMakeRange(i, wrapWidth)]];
[result appendString:@"\r\n"];
}
return result;
}
- (NSString *)base64EncodedString
{
return [self base64EncodedStringWithWrapWidth:0];
}
@end
@implementation NSString (Base64)
+ (NSString *)stringWithBase64EncodedString:(NSString *)string
{
NSData *data = [NSData dataWithBase64EncodedString:string];
if (data)
{
return [[self alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
return nil;
}
- (NSString *)base64EncodedStringWithWrapWidth:(NSUInteger)wrapWidth
{
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
return [data base64EncodedStringWithWrapWidth:wrapWidth];
}
- (NSString *)base64EncodedString
{
NSData *data = [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
return [data base64EncodedString];
}
- (NSString *)base64DecodedString
{
return [NSString stringWithBase64EncodedString:self];
}
- (NSData *)base64DecodedData
{
return [NSData dataWithBase64EncodedString:self];
}
@end

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/AFAutoPurgingImageCache.h

View File

@ -0,0 +1 @@
../../../AFNetworking/AFNetworking/AFHTTPSessionManager.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/AFImageDownloader.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h

View File

@ -0,0 +1 @@
../../../AFNetworking/AFNetworking/AFNetworkReachabilityManager.h

View File

@ -0,0 +1 @@
../../../AFNetworking/AFNetworking/AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/AFNetworking/AFSecurityPolicy.h

View File

@ -0,0 +1 @@
../../../AFNetworking/AFNetworking/AFURLRequestSerialization.h

View File

@ -0,0 +1 @@
../../../AFNetworking/AFNetworking/AFURLResponseSerialization.h

View File

@ -0,0 +1 @@
../../../AFNetworking/AFNetworking/AFURLSessionManager.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIButton+AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIImage+AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIImageView+AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIKit+AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIProgressView+AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h

View File

@ -0,0 +1 @@
../../../AFNetworking/UIKit+AFNetworking/UIWebView+AFNetworking.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFAppLink.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFAppLinkNavigation.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFAppLinkResolving.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFAppLinkReturnToRefererController.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFAppLinkReturnToRefererView.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/Internal/BFAppLinkReturnToRefererView_Internal.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFAppLinkTarget.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/Internal/BFAppLink_Internal.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/BFCancellationToken.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/BFCancellationTokenRegistration.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/BFCancellationTokenSource.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/BFExecutor.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFMeasurementEvent.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/Internal/BFMeasurementEvent_Internal.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/BFTask+Exceptions.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/BFTask.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/BFTaskCompletionSource.h

1
Example/Pods/Headers/Private/Bolts/BFURL.h generated Symbolic link
View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFURL.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/Internal/BFURL_Internal.h

View File

@ -0,0 +1 @@
../../../Bolts/Bolts/iOS/BFWebViewAppLinkResolver.h

1
Example/Pods/Headers/Private/Bolts/Bolts.h generated Symbolic link
View File

@ -0,0 +1 @@
../../../Bolts/Bolts/Common/Bolts.h

View File

@ -0,0 +1 @@
../../../CodFis-Helper/CodFis-Helper/CodFis+Helper.h

View File

@ -0,0 +1 @@
../../../CodFis-Helper/CodFis-Helper/CodFisResponse.h

View File

@ -0,0 +1 @@
../../../CodFis-Helper/CodFis-Helper/ResponseConstants.h

View File

@ -0,0 +1 @@
../../../CodFis-Helper/CodFis-Helper/VatNumber+Helper.h

View File

@ -0,0 +1 @@
../../../DDDKeychainWrapper/Pod/Classes/DDDKeychainWrapper.h

View File

@ -0,0 +1 @@
../../../DJLocalization/DJLocalization/DJLocalizableString.h

View File

@ -0,0 +1 @@
../../../DJLocalization/DJLocalization/DJLocalization.h

View File

@ -0,0 +1 @@
../../../DJLocalization/DJLocalization/DJLocalizationSystem+Private.h

View File

@ -0,0 +1 @@
../../../DJLocalization/DJLocalization/DJLocalizationSystem.h

View File

@ -0,0 +1 @@
../../../DJLocalization/DJLocalization/UIStoryboard+DJLocalization.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/EXPBlockDefinedMatcher.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/EXPDefines.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/EXPDoubleTuple.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/EXPExpect.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/EXPFloatTuple.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/EXPMatcher.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatcherHelpers.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beCloseTo.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beFalsy.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beGreaterThan.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beGreaterThanOrEqualTo.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beIdenticalTo.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beInTheRangeOf.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beInstanceOf.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beKindOf.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beLessThan.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beLessThanOrEqualTo.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beNil.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beSubclassOf.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beSupersetOf.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beTruthy.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+beginWith.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+conformTo.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+contain.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+endWith.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+equal.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+haveCountOf.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+match.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+postNotification.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+raise.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+raiseWithReason.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers+respondTo.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Matchers/EXPMatchers.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/EXPUnsupportedObject.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/Expecta.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/ExpectaObject.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/ExpectaSupport.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/NSObject+Expecta.h

View File

@ -0,0 +1 @@
../../../Expecta/Expecta/NSValue+Expecta.h

Some files were not shown because too many files have changed in this diff Show More