Posted By

BenClayton on 02/08/10


Tagged


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

umang_nine
ericschweichler
stationstops
nsbuckner
Tintenklecks


Compute an MD5 hash on iphone


 / Published in: Objective C
 

  1. #import <CommonCrypto/CommonDigest.h>
  2.  
  3.  
  4. + (NSString *) md5:(NSString *)str {
  5. const char *cStr = [str UTF8String];
  6. unsigned char result[16];
  7. CC_MD5( cStr, strlen(cStr), result );
  8. return [NSString stringWithFormat:
  9. @"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  10. result[0], result[1], result[2], result[3],
  11. result[4], result[5], result[6], result[7],
  12. result[8], result[9], result[10], result[11],
  13. result[12], result[13], result[14], result[15]
  14. ];
  15. }

Report this snippet  

You need to login to post a comment.