Skip to content

Commit

Permalink
Build and project fixes for running on 10.6 (64-bit).
Browse files Browse the repository at this point in the history
  • Loading branch information
rnapier committed Apr 8, 2013
1 parent 76cdd1b commit 3dbab5d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
5 changes: 3 additions & 2 deletions RNCryptor.xcodeproj/project.pbxproj
Expand Up @@ -673,7 +673,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "rncrypt/rncrypt-Prefix.pch";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 10.6;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -696,7 +696,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "rncrypt/rncrypt-Prefix.pch";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
MACOSX_DEPLOYMENT_TARGET = 10.8;
MACOSX_DEPLOYMENT_TARGET = 10.6;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
Expand Down Expand Up @@ -863,6 +863,7 @@
FB6AC69616F6704200CA0C0A /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
FB7564EA1512D3C4007B806B /* Build configuration list for PBXProject "RNCryptor" */ = {
isa = XCConfigurationList;
Expand Down
54 changes: 34 additions & 20 deletions rncrypt/main.m
Expand Up @@ -13,8 +13,10 @@

NSData *GetDataForHex(NSString *hex)
{
NSString *hexNoSpaces = [hex stringByReplacingOccurrencesOfString:@" " withString:@""];

NSString *hexNoSpaces = [[[hex stringByReplacingOccurrencesOfString:@" " withString:@""]
stringByReplacingOccurrencesOfString:@"<" withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""];

NSMutableData *data = [[NSMutableData alloc] init];
unsigned char whole_byte = 0;
char byte_chars[3] = {'\0','\0','\0'};
Expand All @@ -33,6 +35,17 @@ void usage() {
exit(2);
}

void OutputData(NSData *data)
{
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (string) {
printf("%s\n", [string UTF8String]);
}
else {
printf("%s\n", [[data description] UTF8String]);
}
}

int main(int argc, char * const argv[])
{
@autoreleasepool {
Expand All @@ -42,7 +55,7 @@ int main(int argc, char * const argv[])
NSString *message = nil;

char ch;

/* options descriptor */
struct option longopts[] = {
{ "decrypt", no_argument, &decrypt_flag, 1 },
Expand Down Expand Up @@ -71,24 +84,25 @@ int main(int argc, char * const argv[])
message = [NSString stringWithUTF8String:argv[0]];

NSError *error;
NSData *data;
if (decrypt_flag) {
NSData *decryptedData = [RNDecryptor decryptData:GetDataForHex(message)
withPassword:password
error:&error];
if (error) {
NSLog(@"Failed: %@", error);
exit(1);
}
else {
NSString *string = [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];
if (string) {
printf("%s\n", [string UTF8String]);
}
else {
printf("%s\n", [[decryptedData description] UTF8String]);
}
}
data = [RNDecryptor decryptData:GetDataForHex(message)
withPassword:password
error:&error];
}
else {
data = [RNEncryptor encryptData:[message dataUsingEncoding:NSUTF8StringEncoding]
withSettings:kRNCryptorAES256Settings
password:password
error:&error];
}
if (error) {
NSLog(@"Failed: %@", error);
exit(1);
}
else {
OutputData(data);
}
return 0;
}
return 0;
}

0 comments on commit 3dbab5d

Please sign in to comment.