Compute an MD5 hash on iphone


/ Published in: Objective C
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.