一、MD5加解密
demo如下:
#import "ViewController.h"
#import <CommonCrypto/CommonCrypto.h>
#import "Person.h"
-(void)md5{
NSString *str = @"I love sky and sunshine.";
const char *sourceData = [str UTF8String];
// unsigned char resut[CC_MD5_DIGEST_LENGTH];
unsigned char result[CC_MD5_DIGEST_LENGTH];
/**
* 加密长度
*
* @param data#> 数据源 description#>
* @param len#> 数据源的长度 description#>
* @param md#> 计算完成后的结果容器 description#>
*
* @return
*/
CC_MD5(sourceData,(CC_LONG)strlen(sourceData),result);
NSMutableString *md5_str = [NSMutableString string];
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i ++) {
[md5_str appendFormat:@"%02X",result[i]];
}
NSLog(@"简单字符串加密完成--%@",md5_str);