-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,3 +68,5 @@ fastlane/test_output | |
iOSInjectionProject/ | ||
|
||
.DS_Store | ||
|
||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Hasher.h | ||
// TCCKronos | ||
// | ||
// Created by Luke Roberts on 20/11/2023. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface Hasher : NSObject | ||
|
||
+ (NSString *)calculateSHA256ForFileAtPath:(NSString *)path; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// Hasher.m | ||
// TCCKronos | ||
// | ||
// Created by Luke Roberts on 20/11/2023. | ||
// | ||
|
||
#import "Hasher.h" | ||
|
||
#import <CommonCrypto/CommonDigest.h> | ||
|
||
@implementation Hasher | ||
|
||
|
||
+ (NSString *)calculateSHA256ForFileAtPath:(NSString *)path | ||
{ | ||
NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:path]; | ||
if (file == nil) return nil; | ||
|
||
CC_SHA256_CTX hashObject; | ||
CC_SHA256_Init(&hashObject); | ||
|
||
BOOL done = NO; | ||
while (!done) | ||
{ | ||
NSData *fileData = [file readDataOfLength:4096]; | ||
CC_SHA256_Update(&hashObject, [fileData bytes], (CC_LONG)[fileData length]); | ||
if ([fileData length] == 0) done = YES; | ||
} | ||
|
||
unsigned char digest[CC_SHA256_DIGEST_LENGTH]; | ||
CC_SHA256_Final(digest, &hashObject); | ||
[file closeFile]; | ||
|
||
NSMutableString *hash = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH * 2]; | ||
for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) | ||
{ | ||
[hash appendFormat:@"%02x", digest[i]]; | ||
} | ||
|
||
return [hash copy]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters