Created
September 18, 2014 14:48
-
-
Save lerno/8eb04509fc425fe274cf to your computer and use it in GitHub Desktop.
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
//C | |
unsigned char result[CC_MD5_DIGEST_LENGTH]; | |
const char *cString = [self UTF8String]; | |
CC_MD5(cString, (CC_LONG)strlen(cString), result); | |
return bytesToHexString(result, CC_MD5_DIGEST_LENGTH); | |
//Swift | |
let digestLength = 16 | |
var result = Array<UInt8>(count: digestLength, repeatedValue: 0) | |
let cString = cStringUsingEncoding(NSUTF8StringEncoding)! | |
CC_MD5(cString, UInt32(cString.count - 1), &result) | |
return String.bytesToHex(result) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about:
self utf8data md5 toHex