63 lines
1.9 KiB
Objective-C
63 lines
1.9 KiB
Objective-C
|
|
|
|
// Created by duoban on 2024/4/23.
|
|
|
|
|
|
#import "MSParamsDecode.h"
|
|
|
|
@implementation MSParamsDecode
|
|
+ (NSMutableDictionary *)msDecodeParams:(NSMutableDictionary *)params {
|
|
if (!params) {
|
|
params = [NSMutableDictionary dictionary];
|
|
}
|
|
|
|
[params setObject:[MSParamsDecode msSign:[params mutableCopy]] forKey:@"pub_sign"];
|
|
return params;
|
|
}
|
|
|
|
|
|
+ (NSString *)msSign:(NSMutableDictionary *)dic {
|
|
[dic removeObjectForKey:@"Accept-Language"];
|
|
[dic removeObjectForKey:@"pub_uid"];
|
|
[dic removeObjectForKey:@"appVersion"];
|
|
[dic removeObjectForKey:@"appVersionCode"];
|
|
[dic removeObjectForKey:@"channel"];
|
|
[dic removeObjectForKey:@"deviceId"];
|
|
[dic removeObjectForKey:@"ispType"];
|
|
[dic removeObjectForKey:@"netType"];
|
|
[dic removeObjectForKey:@"os"];
|
|
[dic removeObjectForKey:@"osVersion"];
|
|
[dic removeObjectForKey:@"app"];
|
|
[dic removeObjectForKey:@"ticket"];
|
|
[dic removeObjectForKey:@"client"];
|
|
[dic removeObjectForKey:@"channel"];
|
|
[dic removeObjectForKey:@"deviceId"];
|
|
[dic removeObjectForKey:@"lang"];
|
|
[dic removeObjectForKey:@"mcc"];
|
|
|
|
|
|
NSMutableString *stringA = [NSMutableString string];
|
|
|
|
NSArray *sortKeys = [[dic allKeys] sortedArrayUsingSelector:@selector(compare:)];
|
|
|
|
for (NSString *key in sortKeys) {
|
|
[stringA appendString:[NSString stringWithFormat:@"%@=%@&", key, dic[key]]];
|
|
}
|
|
|
|
[stringA appendString:[NSString stringWithFormat:@"key=%@", KeyWithType(KeyType_Sign)]];
|
|
|
|
NSString *stringB = [stringA MD5String];
|
|
|
|
return stringB.uppercaseString;
|
|
}
|
|
|
|
+ (NSString *)uuidString{
|
|
CFUUIDRef uuid_ref = CFUUIDCreate(NULL);
|
|
CFStringRef uuid_string_ref= CFUUIDCreateString(NULL, uuid_ref);
|
|
NSString *uuid = [NSString stringWithString:(__bridge NSString *)uuid_string_ref];
|
|
CFRelease(uuid_ref);
|
|
CFRelease(uuid_string_ref);
|
|
return [uuid lowercaseString];
|
|
}
|
|
@end
|