天天省钱快报

YBMD5.m 787B

1234567891011121314151617181920212223242526272829
  1. //
  2. // MyMD5.m
  3. // GoodLectures
  4. //
  5. // Created by yangshangqing on 11-10-11.
  6. // Copyright 2011年 __MyCompanyName__. All rights reserved.
  7. //
  8. #import "YBMD5.h"
  9. #import "CommonCrypto/CommonDigest.h"
  10. @implementation YBMD5
  11. + (NSString *)md5:(NSString *)inPutText
  12. {
  13. const char *cStr = [inPutText UTF8String];
  14. unsigned char result[CC_MD5_DIGEST_LENGTH];
  15. CC_MD5(cStr, strlen(cStr), result);
  16. return [[NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
  17. result[0], result[1], result[2], result[3],
  18. result[4], result[5], result[6], result[7],
  19. result[8], result[9], result[10], result[11],
  20. result[12], result[13], result[14], result[15]
  21. ] lowercaseString];
  22. }
  23. @end