【发布时间】:2014-03-09 13:31:54
【问题描述】:
我正在使用下面的代码用 md5 散列一个字符串。在我在 64 位 iPad Air 上测试我的应用程序之前,它运行良好。然后它产生了与模拟器不同的输出。
例如字符串@"1111":
- 在模拟器上 = B59C67BF196A4758191E42F76670CEBA
- 在 iPad Air 上 = d41d8cd98f00b204e9800998ecf8427e
这是我的代码:
- (NSString *)MD5String
{
const char *cstr = [self UTF8String];
unsigned char result[16];
CC_MD5(cstr, strlen(cstr), result);
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]
];
}
有什么建议吗?
【问题讨论】:
-
顺便说一句。 d41d8cd98f00b204e9800998ecf8427e 不能是您的方法的输出,因为您的方法只创建大写字母。
标签: ios objective-c md5