md5加密导入库报错解决
2015-05-29 15:20
239 查看
一,用系统自带的MD5进行加密方法一:- (NSString *)md5HexDigest:(NSString*)input{ const char* str = [input UTF8String]; unsigned char result[CC_MD5_DIGEST_LENGTH]; CC_MD5(str, strlen(str), result); NSMutableString *ret = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH*2]; for(int i = 0; i<CC_MD5_DIGEST_LENGTH; i++) { [ret appendFormat:@"%02x",result]; } return ret;}方法二:
- (NSString *)md5:(NSString *)str
{
const char *cStr = [str UTF8String];
unsigned char result[16];
CC_MD5(cStr, 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]
];
}
二,导入系统类库:
#import <CommonCrypto/CommonDigest.h>
三,报错:ld: cannot link directly with /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/lib/system/libcommonCrypto.dylib. Link against the umbrella framework 'System.framework' instead.
四,解决方案:
删去libcommonCrypto.dylib,用System.framework库中的libSystem.dylib替代。
MD5加密和导入库的解决方案分别来自不同出处的网络资源总结,如有侵权,请联系本博主注明。
- (NSString *)md5:(NSString *)str
{
const char *cStr = [str UTF8String];
unsigned char result[16];
CC_MD5(cStr, 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]
];
}
二,导入系统类库:
#import <CommonCrypto/CommonDigest.h>
三,报错:ld: cannot link directly with /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/lib/system/libcommonCrypto.dylib. Link against the umbrella framework 'System.framework' instead.
四,解决方案:
删去libcommonCrypto.dylib,用System.framework库中的libSystem.dylib替代。
MD5加密和导入库的解决方案分别来自不同出处的网络资源总结,如有侵权,请联系本博主注明。
相关文章推荐
- VB实现的16位和32位md5加密代码分享
- Oracle定义DES加密解密及MD5加密函数示例
- Oracle中的MD5加密详解
- mysql与mssql的md5加密语句
- 在Linux中使用MD5实现用户验证的解决方法
- asp.net中使用cookie与md5加密实现记住密码功能的实现代码
- MD5加密
- iOS平台UDID方案比较
- [WP7]MD5加密字符串
- .Net中常用的加密解密介绍
- .Net JAVA JS 加密(三方互通)
- MD5加密
- C#实现MD5加密
- String字符串通过MD5加密(java)
- 22_md5加密密码
- MD5加密代码
- BASE64
- java中MD5加密方法实例
- 为Indy的TIdHashMessageDigest正名
- 类库引用经常报错的问题