20 lines
502 B
Plaintext
20 lines
502 B
Plaintext
include "NSLog.incl"
|
|
include "CommonCrypto/CommonCrypto.incl"
|
|
|
|
void local fn DoIt
|
|
CFStringRef msg = @"Rosetta code"
|
|
ptr rc = fn StringUTF8String( msg )
|
|
unsigned char buf(32)
|
|
fn CC_SHA256( rc, fn strlen(rc), @buf(0) )
|
|
CFMutableStringRef res = fn MutableStringWithCapacity(CC_SHA256_DIGEST_LENGTH)
|
|
for int i = 0 to CC_SHA256_DIGEST_LENGTH - 1
|
|
MutableStringAppendFormat( res, @"%02x", buf(i) )
|
|
next
|
|
NSLog(@"Input:\n%@\n",msg)
|
|
NSLog(@"Output:\n%@", res)
|
|
end fn
|
|
|
|
fn DoIt
|
|
|
|
HandleEvents
|