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?
You need to use:
NSString *credentials = [self md5:@"test"]; //[md5 @"test"];
If you are calling this method from the class that has method md5:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With