SHA-256: Difference between revisions
Content added Content deleted
No edit summary |
(Fixed to use digest instead of HMAC.) |
||
Line 803: | Line 803: | ||
=={{header|Objective-C}}== |
=={{header|Objective-C}}== |
||
Build with something like |
|||
{{incorrect|Objective-C}} |
|||
<pre> |
|||
⚫ | |||
clang -o rosetta_sha256 rosetta_sha256.m /System/Library/Frameworks/Cocoa.framework/Cocoa |
|||
</pre> |
|||
@implementation AppDelegate |
|||
or in XCode. |
|||
⚫ | |||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { |
|||
#import <CommonCrypto/CommonDigest.h> |
|||
⚫ | |||
NSString* data = @"Message"; |
|||
⚫ | |||
const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding]; |
|||
⚫ | |||
CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
int main(int argc, char ** argv) { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
if (! CC_SHA256(rc, strlen(rc), buf)) { |
|||
NSLog(@"Failure..."); |
|||
return -1; |
|||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
⚫ | |||
return 0; |
|||
} |
|||
⚫ | |||
=={{header|OCaml}}== |
=={{header|OCaml}}== |