All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fastchar.security.template.md5_ios Maven / Gradle / Ivy

+ (void)sign:(NSMutableDictionary *)params{
    [params removeObjectForKey:@"sign"];

    NSString *timestamp = [NSString stringWithFormat:@"%@", @([[NSDate date] timeIntervalSince1970] * 1000)];
    [params setValue:timestamp forKey:@"timestamp"];

    NSArray *keysArray = [params allKeys];
    NSArray *resultArray = [keysArray sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
        return [obj1 compare:obj2 options:NSNumericSearch];
    }];

    NSString *waitSign = @"";
    for (NSString *key in resultArray) {
        id value = params[key];
        if (value == NULL)continue;
        if ([CrosheStringUtils isEmpty:value])continue;
        if ([value isKindOfClass:[NSURL class]]
                || [value isKindOfClass:[UIImage class]])
            continue;

        waitSign = [waitSign stringByAppendingString:[NSString stringWithFormat:@"%@=%@;", key,value]];
    }
    waitSign = [waitSign stringByAppendingString:@"key=${key};"];

    //此处使用MD5工具类加密后,以sign参数名称提交到后台即可!
    NSString *sign = [BaseUtils MD5:waitSign];
    [params setValue:sign forKey:@"sign"];
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy