8

I have found this md5 function here: http://www.makebetterthings.com/iphone/how-to-get-md5-and-sha1-in-objective-c-ios-sdk/

- (NSString *) md5:(NSString *) input
{
 const char *cStr = [input UTF8String];
 unsigned char digest[16];
 CC_MD5( cStr, strlen(cStr), digest ); // This is the md5 call

 NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];

 for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
 [output appendFormat:@"%02x", digest[i]];

 return  output;

}

I have the signature in my header file like this:

- (NSString *) md5:(NSString *) input;

There is no errors showing up in xCode, except where i try to use the function.

NSString *credentials = [md5 @"test"];

I get the message: Use of undeclared identifier 'md5'

How do i use this function?

user1359448
  • 1,539
  • 3
  • 14
  • 23
  • @H2CO3: This will come handy for him, what say you http://stackoverflow.com/questions/13575037/what-are-resources-for-learning-objective-c – Anoop Vaidya Mar 13 '13 at 18:35
  • @H2CO3: did you see my question here http://stackoverflow.com/questions/15392726/does-synchronized-guarantees-for-thread-safe-or-not – Anoop Vaidya Mar 13 '13 at 18:35

1 Answers1

9

You need to use:

NSString *credentials = [self md5:@"test"]; //[md5 @"test"];

If you are calling this method from the class that has method md5:

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140