I am working on an app which needs to send the data on server in MD5 encoded string. In Objective C MD5 string is generated something like:
*68da55b645ef7fef43d4df4910a30a0d*
where as on PHP side the MD5 string is generated something like:
*c16a5320fa475530d9583c34fd356ef5*.
Here both are not generating same so it creates problem.
Below is my code to generate the MD5 string in Objective C.
- (NSString *)md5
{
const char *cStr = [self UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5( cStr, (int)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",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
];
}
In PHP the MD5 string is generated using MD5.min.js This issue rejects my API calls. Any idea how to make it identical? Ideally it should generate the same on both the sides but it is not generating.
Any help would be appreciated!!!