Objective C MD5和PHP MD5都生成不同的字符串

时间:2016-05-24 13:12:08

标签: php ios objective-c

我正在开发一个需要在服务器上以MD5编码的字符串发送数据的应用程序。在目标C 中生成MD5字符串,如:

*68da55b645ef7fef43d4df4910a30a0d* 

PHP 一侧,MD5字符串的生成类似于:

  *c16a5320fa475530d9583c34fd356ef5*. 

这里两者都没有相同,所以它会产生问题。

以下是我在目标C 中生成MD5字符串的代码。

- (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]
        ];  
}

在PHP中,使用 MD5.min.js 生成MD5字符串 此问题拒绝我的API调用。知道如何使它相同吗?理想情况下,它应该在两侧生成相同但不生成。

任何帮助将不胜感激!!!

0 个答案:

没有答案
相关问题