MD5 加密 代码

时间:2021-06-28 08:33:26

/*!

获取MD5 加密串

*/

+(NSString *)getAuthorization:(NSString *)type Date:(NSDate *)date UserSecret:(NSString *)userSecret URL:(NSString *)url{

//判断是不是为 nil

if (!type|| !date || !userSecret ||!url) {

return nil;

}

NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];

[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

NSTimeZone *tzGMT = [NSTimeZone timeZoneWithName:@"GMT"];

[dateFormatter setTimeZone:tzGMT];

NSString *time=[dateFormatter stringFromDate:date];

//拼接字符串

NSMutableString *mustr_Auth=[NSMutableString stringWithString:@"8B3EC424-7EF8-4627-8450-45415000EEBA"];

[mustr_Auth appendString:type];

[mustr_Auth appendString:@",,"];

[mustr_Auth appendString:time];

[mustr_Auth appendString:@",iosApp,"];

[mustr_Auth appendString:userSecret];

[mustr_Auth appendString:@","];

[mustr_Auth appendString:[url lowercaseString ]];

return [[NSString_MD5 MD5EncryptBy32:mustr_Auth] lowercaseString];

}