开发者

MD5 code generation

I have a query regarding MD5 code generation. My page has 4 fields, like user name, password.

I need MD5 code generation for password fields. My MD5 code conversion code is perfect, there is no error, but when I run the application, it crashes.

I exactly don't know how to convert my p开发者_JS百科assword field with my conversion code. I need help as I am new to iPhone development. Code would be appreciated.


I've used this in the past. You might find it helpful.

- (NSString *)stringWithMD5Hash:(NSString *)inStr {
    const char *cStr = [inStr UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    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] ];
}

This requires importing CommonCrypto/CommonDigest.h.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜