in Objective-c, we can hash a string like this:
const char *cStr = [someString UTF8String];
unsigned char result[16];
CC_MD5( cStr, strlen(cStr), result );
m
evntually if you want calculate MD5 out of NSData, take a look at this:
func md5() -> NSData {
var ctx = UnsafePointer.alloc(sizeof(CC_MD5_CTX))
CC_MD5_Init(ctx);
CC_MD5_Update(ctx, self.bytes, UInt32(self.length));
let length = Int(CC_MD5_DIGEST_LENGTH) * sizeof(Byte)
var output = UnsafePointer.alloc(length)
CC_MD5_Final(output, ctx);
let outData = NSData(bytes: output, length: Int(CC_MD5_DIGEST_LENGTH))
output.destroy()
ctx.destroy()
//withUnsafePointer
return outData;
}
to get idea.