Today's Menu  Portugal
journal and plan nutrition
NSString+MD5.m
Go to the documentation of this file.
1 //
2 // NSString+MD5.m
3 // CoordMedicRove
4 //
5 // Created by Don Zeek on 4/25/14.
6 // Copyright (c) 2014 net.dzeek.cp125a. All rights reserved.
7 //
8 
9 #import "NSString+MD5.h"
10 #import <CommonCrypto/CommonDigest.h>
11 @implementation NSString (MD5)
12 
13 - (NSString*)generateMD5Hash
14 {
15  const char *string = [self UTF8String];
16  unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
17  CC_MD5(string, (unsigned int)strlen(string), md5Buffer);
18  NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
19  for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
20  [output appendFormat:@"%02x",md5Buffer[i]];
21  return output;
22 }
23 @end
NSString * generateMD5Hash()
Definition: NSString+MD5.m:13