Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove Base64 #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "submodules/Base64"]
path = submodules/Base64
url = https://github.com/nicklockwood/Base64.git
ignore = dirty
[submodule "submodules/xctool"]
path = submodules/xctool
url = https://github.com/facebook/xctool.git
Expand Down
16 changes: 0 additions & 16 deletions CocoaSecurity.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
21540A04183DD7F000E4C15B /* CocoaSecurityEncoder_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 21540A00183DD7F000E4C15B /* CocoaSecurityEncoder_Tests.m */; };
21540A05183DD7F000E4C15B /* CocoaSecurityResult_Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 21540A01183DD7F000E4C15B /* CocoaSecurityResult_Test.m */; };
21540A06183DD81A00E4C15B /* CocoaSecurity.m in Sources */ = {isa = PBXBuildFile; fileRef = 2113924116EAD6AF00AFDF87 /* CocoaSecurity.m */; };
21FB346C189601A6002F38DE /* Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 21FB346B189601A6002F38DE /* Base64.m */; };
21FB346D18960347002F38DE /* Base64.m in Sources */ = {isa = PBXBuildFile; fileRef = 21FB346B189601A6002F38DE /* Base64.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -61,8 +59,6 @@
21540A00183DD7F000E4C15B /* CocoaSecurityEncoder_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocoaSecurityEncoder_Tests.m; sourceTree = "<group>"; };
21540A01183DD7F000E4C15B /* CocoaSecurityResult_Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocoaSecurityResult_Test.m; sourceTree = "<group>"; };
21BB8A2E17FEA0EC0032C38C /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
21FB346A189601A6002F38DE /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Base64.h; path = submodules/Base64/Base64/Base64.h; sourceTree = SOURCE_ROOT; };
21FB346B189601A6002F38DE /* Base64.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Base64.m; path = submodules/Base64/Base64/Base64.m; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -119,7 +115,6 @@
2113923C16EAD6AF00AFDF87 /* CocoaSecurity */ = {
isa = PBXGroup;
children = (
21FB34691896019A002F38DE /* Submodules */,
2113923F16EAD6AF00AFDF87 /* CocoaSecurity.h */,
2113924116EAD6AF00AFDF87 /* CocoaSecurity.m */,
);
Expand Down Expand Up @@ -148,15 +143,6 @@
name = "Supporting Files";
sourceTree = "<group>";
};
21FB34691896019A002F38DE /* Submodules */ = {
isa = PBXGroup;
children = (
21FB346A189601A6002F38DE /* Base64.h */,
21FB346B189601A6002F38DE /* Base64.m */,
);
name = Submodules;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -242,7 +228,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
21FB346C189601A6002F38DE /* Base64.m in Sources */,
2113924216EAD6AF00AFDF87 /* CocoaSecurity.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -251,7 +236,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
21FB346D18960347002F38DE /* Base64.m in Sources */,
21540A06183DD81A00E4C15B /* CocoaSecurity.m in Sources */,
21540A05183DD7F000E4C15B /* CocoaSecurityResult_Test.m in Sources */,
21540A03183DD7F000E4C15B /* CocoaSecurityDecoder_Tests.m in Sources */,
Expand Down
27 changes: 24 additions & 3 deletions CocoaSecurity/CocoaSecurity.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#import "CocoaSecurity.h"
#import <CommonCrypto/CommonHMAC.h>
#import <CommonCrypto/CommonCryptor.h>
#import "Base64.h"

#pragma mark - CocoaSecurity
@implementation CocoaSecurity
Expand Down Expand Up @@ -420,7 +419,17 @@ @implementation CocoaSecurityEncoder
// convert NSData to Base64
- (NSString *)base64:(NSData *)data
{
return [data base64EncodedString];
NSString *base64String;
#if ((defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9) || \
(defined __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0))
base64String = [data base64EncodedStringWithOptions:0];
#else
if ([data respondsToSelector:@selector(base64EncodedStringWithOptions:)]) {
base64String = [data base64EncodedStringWithOptions:0];
}
base64String = [data base64Encoding];
#endif
return [base64String length] == 0 ? nil : base64String;
}

// convert NSData to hex string
Expand Down Expand Up @@ -467,8 +476,20 @@ - (NSString *)hex:(NSData *)data useLower:(BOOL)isOutputLower
@implementation CocoaSecurityDecoder
- (NSData *)base64:(NSString *)string
{
return [NSData dataWithBase64EncodedString:string];
if ([string length] == 0) {
return nil;
}
#if ((defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_9) || \
(defined __IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_0))
return [[NSData alloc] initWithBase64EncodedString:string options:0];
#else
if ([NSData instancesRespondToSelector:@selector(initWithBase64EncodedString:options:)]) {
return [[NSData alloc] initWithBase64EncodedString:string options:0];
}
return [[NSData alloc] initWithBase64Encoding:string];
#endif
}

- (NSData *)hex:(NSString *)data
{
if (data.length == 0) { return nil; }
Expand Down
1 change: 0 additions & 1 deletion submodules/Base64
Submodule Base64 deleted from bff0cc