Javier Cicchelli 9bcdaa697b [Setup] Basic project structure (#1)
This PR contains all the work related to setting up this project as required to implement the [Assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) on top, as intended.

To summarise this work:
- [x] created a new **Xcode** project;
- [x] cloned the `Wikipedia` app and inserted it into the **Xcode** project;
- [x] created the `Locations` app and also, its `Libraries` package;
- [x] created the `Shared` package to share dependencies between the apps;
- [x] added a `Makefile` file and implemented some **environment** and **help** commands.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: rock-n-code/deep-linking-assignment#1
2023-04-08 18:37:13 +00:00

36 lines
832 B
Objective-C

#import "NSString+SHA256.h"
#import <CommonCrypto/CommonCrypto.h>
@implementation NSData (SHA256)
- (NSString *)SHA256 {
CC_SHA256_CTX hashObject;
CC_SHA256_Init(&hashObject);
NSUInteger length = [self length];
const void *buffer = [self bytes];
CC_SHA256_Update(&hashObject,
(const void *)buffer,
(CC_LONG)length);
unsigned char digest[CC_SHA256_DIGEST_LENGTH];
CC_SHA256_Final(digest, &hashObject);
char hash[2 * sizeof(digest) + 1];
for (size_t i = 0; i < sizeof(digest); ++i) {
snprintf(hash + (2 * i), 3, "%02x", (int)(digest[i]));
}
return [[NSString alloc] initWithUTF8String:hash];
}
@end
@implementation NSString (SHA256)
- (NSString *)SHA256 {
return [[self dataUsingEncoding:NSUTF8StringEncoding] SHA256];
}
@end