Today's Menu  Portugal
journal and plan nutrition
NSData+MD5.m
Go to the documentation of this file.
1 //
2 // NSData+MD5.m
3 // CoordMedicRove
4 //
5 // Created by Don Zeek on 6/9/14.
6 // Copyright (c) 2014 net.dzeek.cp125a. All rights reserved.
7 //
8 
9 #import "NSData+MD5.h"
10 #import <CommonCrypto/CommonDigest.h>
11 
12 @implementation NSData (MD5)
13 
14 - (NSString*)MD5
15 {
16  // Create byte array of unsigned chars
17  unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
18 
19  // Create 16 byte MD5 hash value, store in buffer
20  CC_MD5(self.bytes, (unsigned int)self.length, md5Buffer);
21 
22  // Convert unsigned char buffer to NSString of hex values
23  NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
24  for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
25  [output appendFormat:@"%02x",md5Buffer[i]];
26 
27  return output;
28 }
29 
30 @end
NSString * MD5()
Definition: NSData+MD5.m:14