MD5 algorithm in Objective C?

Md5 is available on the iPhone and can be added as an extension for ie NSString and NSData like below MyExtensions. H interface NSString (MyExtensions) - (NSString *) md5; @end @interface NSData (MyExtensions) - (NSString*)md5; @end MyExtensions. M import "MyExtensions.

H" #import // Need to import for CC_MD5 access @implementation NSString (MyExtensions) - (NSString *) md5 { const char *cStr = self UTF8String; unsigned char result16; CC_MD5( cStr, strlen(cStr), result ); // This is the md5 call return NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15 ; } @end @implementation NSData (MyExtensions) - (NSString*)md5 { unsigned char result16; CC_MD5( self. Bytes, self. Length, result ); // This is the md5 call return NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15 ; } @end EDIT Added NSData md5 because I needed it myself and thought this is a good place to save this little snippet.

Md5 is available on the iPhone and can be added as an extension for ie NSString and NSData like below. MyExtensions. H @interface NSString (MyExtensions) - (NSString *) md5; @end @interface NSData (MyExtensions) - (NSString*)md5; @end MyExtensions.

M #import "MyExtensions. H" #import // Need to import for CC_MD5 access @implementation NSString (MyExtensions) - (NSString *) md5 { const char *cStr = self UTF8String; unsigned char result16; CC_MD5( cStr, strlen(cStr), result ); // This is the md5 call return NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15 ; } @end @implementation NSData (MyExtensions) - (NSString*)md5 { unsigned char result16; CC_MD5( self. Bytes, self.

Length, result ); // This is the md5 call return NSString stringWithFormat: @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12, result13, result14, result15 ; } @end EDIT Added NSData md5 because I needed it myself and thought this is a good place to save this little snippet...

4 Great little snippet - thanks (+1). – jkp Jun 9 '10 at 10:08.

This has been asked before here on stackoverflow: stackoverflow.com/questions/652300/using....

If anyone was looking for a solution to this for a REST API implementation, like I was for hours. You can check out my blog for the solution. I was able to produce a correctly formatted utf-8 MD5 hash all in lower case using a class method that I produced.

See it here saobart.com/md5-has-in-objective-c.

Md5 is available on the iPhone and can be added as an extension for ie NSString and NSData like below. This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

Not the answer you're looking for?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions