-
-
Save kean/f5e1975e01d5e0c8024bc35556665d7b to your computer and use it in GitHub Desktop.
SHA1
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
// | |
// Use this file to import your target's public headers that you would like to expose to Swift. | |
// | |
#import "SHA1.h" |
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
// The MIT License (MIT) | |
// | |
// Copyright (c) 2015-2018 Alexander Grebenyuk (github.com/kean). | |
#import <Foundation/Foundation.h> | |
/// Produces 160-bit hash value using SHA-1 algorithm. | |
/// - returns: String containing 160-bit hash value expressed as a 40 digit | |
/// hexadecimal number. | |
extern NSString * | |
_nuke_sha1(const char *data, uint32_t length); |
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
// The MIT License (MIT) | |
// | |
// Copyright (c) 2015-2018 Alexander Grebenyuk (github.com/kean). | |
#import <Foundation/Foundation.h> | |
#import <CommonCrypto/CommonCrypto.h> | |
NSString * | |
_nuke_sha1(const char *data, uint32_t length) { | |
unsigned char hash[CC_SHA1_DIGEST_LENGTH]; | |
CC_SHA1(data, (CC_LONG)length, hash); | |
char utf8[2 * CC_SHA1_DIGEST_LENGTH + 1]; | |
char *temp = utf8; | |
for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) { | |
snprintf(temp, 3, "%02x", hash[i]); | |
temp += 2; | |
} | |
return [NSString stringWithUTF8String:utf8]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment