frida-trace -UF -m "-[DTRpcConfig isAMRPC]"
onEnter(log, args, state) {
log(`-[DTRpcConfig isAMRPC] ~~~~~`);
var customObj = new ObjC.Object(args[0]); // 自定义对象
// 打印该对象所有属性
var ivarList = customObj.$ivars;
for (key in ivarList) {
log(`key${key}=${ivarList[key]}`);
}
customObj.setIsAMRPC_(false);
log(`-[DTRpcConfig isAMRPC] --`+customObj.isAMRPC());
}
+(NSString*)identifier{
NSString *embeddedPath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"];
// 读取application-identifier 注意描述文件的编码要使用:NSASCIIStringEncoding
NSString *embeddedProvisioning = [NSString stringWithContentsOfFile:embeddedPath encoding:NSASCIIStringEncoding error:nil];
NSArray *embeddedProvisioningLines = [embeddedProvisioning componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
BOOL isJr = NO;//如果embedded 文件被删除 则不会进入
for (int i = 0; i < embeddedProvisioningLines.count; i++) {
if ([embeddedProvisioningLines[i] rangeOfString:@"application-identifier"].location != NSNotFound) {
isJr = YES;
NSInteger fromPosition = [embeddedProvisioningLines[i+1] rangeOfString:@"<string>"].location+8;
NSInteger toPosition = [embeddedProvisioningLines[i+1] rangeOfString:@"</string>"].location;
NSRange range;
range.location = fromPosition;
range.length = toPosition - fromPosition;
NSString *fullIdentifier = [embeddedProvisioningLines[i+1] substringWithRange:range];
NSArray *identifierComponents = [fullIdentifier componentsSeparatedByString:@"."];
NSString *appIdentifier = [identifierComponents firstObject];
return appIdentifier;
break;
}
}
return @"nil";
}
//发送数据1
%hook DTRpcClient
- (id)executeMethod:(id)arg1 params:(id)arg2 requestHeaderField:(id)arg3 responseHeaderFields:(id )arg4{
// NSString *blockDescription2 = [ZLJPrinter printBlock:arg4];
// NSLog(@"%@",blockDescription2);// arg1 DTRpcMethod *
if([xddTools alipayHttpHookURL2:self params:arg1]){
int sdfldlf = 1;
}
id s = %orig;
return s; //发送数据
}
//hook 发送HTTP请求2
+(_Bool)alipayHttpHookURL2:(DTRpcClient*)client params:(DTRpcMethod*)method
{
NSURL *gatewayURL = client.configManager.globalConfig.gatewayURL;
// client.configManager.globalConfig.isAMRPC = false;//通用
if(gatewayURL && method.operationType){
client.configManager.globalConfig.isAMRPC = false;//通用
// 任务列表 Call
if([ method.operationType isEqualToString:@"alipay.antforest.forest.h5.queryTaskList"]){
// client.configManager.globalConfig.networkActivityIndicatorVisible = false;
// client.configManager.globalConfig.requestGZip = false;
client.configManager.globalConfig.isAMRPC = false;//关键Call
// client.configManager.globalConfig.shouldAppendCTUExtraParams = true;
// client.configManager.globalConfig.ignoreInterceptor = true;
// client.configManager.globalConfig.canResend = true;
client.configManager.globalConfig.gatewayURL = [NSURL URLWithString:@"https://sign.xxx.com/dsadsa.php"];
return YES;
}
}
return NO;
}
// 得到当前本地时间,13位,整形
+ (long long)gs_getCurrentTimeToMilliSecond {
double currentTime = [[NSDate date] timeIntervalSince1970] * 1000;
long long iTime = (long long)currentTime;
return iTime;
}
//得到当前时间相对1970时间的字符串,精度到秒,返回10位长度字符串
+ (NSString *)gs_getCurrentTimeBySecond {
double currentTime = [[NSDate date] timeIntervalSince1970];
NSString *strTime = [NSString stringWithFormat:@"%.0f",currentTime];
return strTime;
}
/** 得到当前时间相对1970时间的字符串,精度到毫秒,返回13位长度字符串*/
+ (NSString *)gs_getCurrentTimeStringToMilliSecond {
double currentTime = [[NSDate date] timeIntervalSince1970]*1000;
NSString *strTime = [NSString stringWithFormat:@"%.0f",currentTime];
return strTime;
}
//测试j加密
+(void)TestHttpmmmmm
{
// [xddTools TestHttpmmmmm];
DTURLRequestOperation*op = [[NSClassFromString(@"DTURLRequestOperation") alloc] init];
NSString*retmd5 = [op rpcV1Sign:@"asdasdas" newSign:false request:0];
NSLog(@"%@",retmd5);
}
//获取数据签名,dic(data,call)
+(NSDictionary*)getAlipaysignV1:(NSDictionary*)dic
{
NSString *type = @"";
NSString *basStr = @"";
NSString *extParam = @"";
if(dic[@"data"] && dic[@"call"] && dic[@"extParam"]){
basStr = dic[@"data"];
type = dic[@"call"];
extParam = dic[@"extParam"];
}else{
return [NSDictionary dictionaryWithObjectsAndKeys:
@"is data or call extParam to null?",@"data"
,nil];;
}
long long time13 = [self gs_getCurrentTimeToMilliSecond];
NSString *basTime = [NSClassFromString(@"DTRpcUtils") c10to64:time13];
//加密数据
//operationType=alipay.antforest.forest.h5.queryTaskList&requestData=[{\"version\":\"20191225\"}]&scene=active&ts=NKGPVxc
NSString*sText = [NSString stringWithFormat:@"extParam=%@&operationType=%@&requestData=%@&ts=%@",
extParam,
type,
basStr,
basTime
];
NSDictionary *paDict = [NSDictionary dictionaryWithObjectsAndKeys:
sText,@"input"
,nil];
//构造加密数据
OpenSecurityGuardParamContext *param = [NSClassFromString(@"OpenSecurityGuardParamContext") createParamContextWithAppKey:@"rpc-sdk-online" paramDict:paDict requestType:4];
//获取加密类管理器
OpenSecurityGuardManager*guardManager = [NSClassFromString(@"OpenSecurityGuardManager") getInstance];
//获取签名class
SecurityGuardOpenSecureSignature *secureSignature = [guardManager getSecureSignatureComp];
//调用签名
NSString*smd5 = [secureSignature signRequest:param authCode:0];
NSLog(@"加密解结果:%@",smd5);
NSDictionary *retDict = [NSDictionary dictionaryWithObjectsAndKeys:
// @(time13),@"time13",
basTime,@"Ts",
smd5,@"sign",
nil];
return retDict;
}
//获取数据签名,dic(data,call)
+(NSDictionary*)getAlipaysign:(NSDictionary*)dic
{
NSString *type = @"";
NSString *basStr = @"";
if(dic[@"data"] && dic[@"call"]){
basStr = dic[@"data"];
type = dic[@"call"];
}else{
return [NSDictionary dictionaryWithObjectsAndKeys:
@"is data or call to null?",@"data"
,nil];;
}
long long time13 = [self gs_getCurrentTimeToMilliSecond];
NSString *basTime = [NSClassFromString(@"DTRpcUtils") c10to64:time13];
//加密数据
//Operation-Type=alipay.antforest.forest.h5.queryTaskList&Request-Data=W3sidmVyc2lvbiI6IjIwMTkxMjI1In1d&Ts=NJqbLtC
NSString*sText = [NSString stringWithFormat:@"Operation-Type=%@&Request-Data=%@&Ts=%@",
type,
basStr,
basTime
];
NSDictionary *paDict = [NSDictionary dictionaryWithObjectsAndKeys:
sText,@"input"
,nil];
//构造加密数据
OpenSecurityGuardParamContext *param = [NSClassFromString(@"OpenSecurityGuardParamContext") createParamContextWithAppKey:@"rpc-sdk-online" paramDict:paDict requestType:4];
//获取加密类管理器
OpenSecurityGuardManager*guardManager = [NSClassFromString(@"OpenSecurityGuardManager") getInstance];
//获取签名class
SecurityGuardOpenSecureSignature *secureSignature = [guardManager getSecureSignatureComp];
//调用签名
NSString*smd5 = [secureSignature signRequest:param authCode:0];
NSLog(@"加密解结果:%@",smd5);
NSDictionary *retDict = [NSDictionary dictionaryWithObjectsAndKeys:
// @(time13),@"time13",
basTime,@"Ts",
smd5,@"sign",
nil];
return retDict;
}
//签名测试
+(void)tttttsign{
// [xddTools tttttsign];
[[NSDate date] timeIntervalSince1970];
//arg1 unsigned long long 1601878192164
//1601878192164
//1601878628380
long long tttime = 1601878192164;
tttime = [self gs_getCurrentTimeToMilliSecond];
NSString*basTime = [NSClassFromString(@"DTRpcUtils") c10to64:tttime];//(unsigned long long)arg1
//加密数据
NSString*sText = @"Operation-Type=alipay.antforest.forest.h5.queryTaskList&Request-Data=W3sidmVyc2lvbiI6IjIwMTkxMjI1In1d&Ts=NJqbLtC";
sText = @"Operation-Type=alipay.antforest.forest.h5.queryTaskList&Request-Data=W3sidmVyc2lvbiI6IjIwMTkxMjI1In1d&Ts=NJoFt0v";
sText = @"Operation-Type=ali.user.gw.unifyLogin.hpb&Request-Data=CgRxcXFxEgZBTElQQVkaCDIzNTk0MDQ3IAEoBzIAOqwBVzRkaHBtT0tFUXg1VWJjMkNMYmY1ZGcvSk5kandtZWtvbnE5WVZOeEx6SnBVWVhVTmVOeFZmelJ1cjNkWTlDOVl6U2hRYndWcEtRaE1NUnA1SmdzazJYYTJmV3Q5QjFxYjV5YXc4K21ORE5sVEFqa0pacEJ1aWxrdWhUampQOE9UL2lGQ0c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uMC4zNTDKAhgKBXZpbWVpEg9zZ3Myamtzc3BkcWwzcm3SAg8KB25ldFR5cGUSBFdXQU7SAi4KFGFmdGVyTG9naW5TeW5jQ29uZmlnEhZ7ICAiZmFjZVN0YXR1cyIgOiAiTiJ90gKgAQoDbGRmEpgBTVlGS0NvNlRwUWV4VjBwNlZacDY3RllzeTFWTTUwV0J3ZVNxWkZXdldUOFJWQjUwb0lSWGJza2RrS01IZThONnFIYW51Z0NVRFNxT2VsWklSRG5sUkd6Smh3RVRESzAvYWhlcmlCNjJDSGhrYVdjYVdwTVZwOG9oMXBVSCtyK1ltcEI0blFhWUlSL3ZTbnFvNjJXaTc0TT3SAhMKDmFwZGlkRG93bmdyYWRlEgFO0gI4CghlZGdlRGF0YRIsS0o1c2VvMmVBNm9HYUozQkFNUGFXaFlRT0Q1dDZSNjNoTFdHQ01kaVc4Yz3SAlgKCWRldktleVNldBJLeyJhcGRpZFRva2VuIjoiS2VzRGc2bU5pWXVBXC9zbGlac2h5UUE5V2tcL2l2TklrcFJEWjhCdjQ3eWRGaGwxM2N3UStDZUFFQiJ92gIHMi4wLjAuNA==&Ts=NY6j5xV";
NSDictionary *paDict = [NSDictionary dictionaryWithObjectsAndKeys:
sText,@"input"
,nil];
//构造加密数据
OpenSecurityGuardParamContext *param = [NSClassFromString(@"OpenSecurityGuardParamContext") createParamContextWithAppKey:@"rpc-sdk-online" paramDict:paDict requestType:4];
//获取加密类管理器
OpenSecurityGuardManager*guardManager = [NSClassFromString(@"OpenSecurityGuardManager") getInstance];
//获取签名class
SecurityGuardOpenSecureSignature *secureSignature = [guardManager getSecureSignatureComp];
//调用签名
NSString*sMd5 = [secureSignature signRequest:param authCode:0];
NSLog(@"加密解结果:%@",sMd5);
int asf =1;
//NSString*sMd5 = [NSClassFromString(@"SecurityGuardOpenSecureSignature") signRequest:param authCode:0];
}
//获取cookies
+(void)getAlipaycookies
{
// [xddTools getAlipaycookies];
NSString *cookies = [NSClassFromString(@"APAppInfoProvider") getCookieSessionId];
NSLog(@"getCookieSessionId.cookies=%@",cookies);
APAppInfoProvider*ider = [[NSClassFromString(@"APAppInfoProvider") alloc] init];
APMAInitInfo* info = [ider getInitInfo];
NSDictionary*infoDic = [info info];
NSString *userId = infoDic[@"userId"];
NSString *utdid = infoDic[@"utdid"];
NSLog(@"getCookieSessionId.userId=%@",userId);
NSLog(@"getCookieSessionId.utdid=%@",utdid);
// _info __NSDictionaryM * 17 key/value pairs 0x000000010c0383c0
// [0] (null) "imsi" : "46000fkydms3sbm"
// [1] (null) "clientType" : "phone"
// [2] (null) "mobileBrand" : "apple"
// [3] (null) "productID" : "IPHONE_1ND"
// [4] (null) "longitude" : "107.213615"
// [5] (null) "appType" : "client"
// [6] (null) "latitude" : "30.742227"
// [7] (null) "channels" : "apple-iphone"
// [8] (null) "apdid" : "eYOIkhvmPflYK2HBf23lsMgMR9BT4H3fjz5Xf45vRIkEiZTWE51k3dO9"
// [9] (null) "Language" : "zh-Hans"
// [10] (null) "imei" : "7j29i82sfabv3hi"
// [11] (null) "productVersion" : "10.1.95.7030"
// [12] (null) "AppName" : "ALIPAY_WALLET"
// [13] (null) "userId" : "208843xxxxxxx"
// [14] (null) "only_to_link" : "T"
// [15] (null) "latLonTime" : "1602344704644"
// [16] (null) "utdid" : "XLHljFMLm88DAB994Fe13IYf"
// 复制剪切板
// NSString*textInfo = [NSString stringWithFormat:@"cookies=%@,userId=%@,utdid=%@",cookies,userId,utdid];
// UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
// pasteboard.string = textInfo;
// dispatch_async(dispatch_get_main_queue(), ^{
// [UIView xx_makeBottomToast:textInfo];
// });
if(!cookies || !userId || !utdid){
dispatch_async(dispatch_get_main_queue(), ^{
[UIView xx_makeBottomToast:@"请稍后再试,未初始化完毕~"];
});
return;
}else{
dispatch_async(dispatch_get_main_queue(), ^{
[UIView xx_makeBottomToast:@"正在授权服务~"];
});
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[self xffadmi2:userId did:utdid cookies:cookies];
});
}
}
//获取合种永久二维码
+(NSDictionary *)gethezhongqrCode:(NSString*)code
{
if(code == nil || [code isEqualToString:@""]){
//https://qr.alipay.com/fcx16984yzm5vswn6rxaa6c?_s=web-other
code = @"https://qr.alipay.com/fcx16984yzm5vswn6rxaa6c";
}
//_operationType __NSCFConstantString * "alipay.mobilecodec.route" 0x0000000103ab3048
DTRpcMethod*arg1 = [[NSClassFromString(@"DTRpcMethod") alloc] init];
arg1.operationType = @"alipay.mobilecodec.route";
arg1.returnType = @"NSDictionary";
// arg2 __NSSingleObjectArrayI * 1 element
// [0] MOBILECODECRouteCommandReq *
//[0] (null) "code" : "https://qr.alipay.com/fcx16984yzm5vswn6rxaa6c?_s=web-other"
NSDictionary *decode = [NSDictionary dictionaryWithObjectsAndKeys:
code,@"code"
,nil];
MOBILECODECRouteCommandReq *req = [[NSClassFromString(@"MOBILECODECRouteCommandReq") alloc] init];
// _paiType __NSCFConstantString * "qrCode"
// _decodeData __NSDictionaryM * 1 key/value pair
// [0] (null) "code" : "https://qr.alipay.com/fcx16984yzm5vswn6rxaa6c?_s=web-other"
req.paiType = @"qrCode";
req.decodeData = decode;
NSArray *arg2 = @[req];
DTRpcClient *call = [NSClassFromString(@"DTRpcClient") defaultClient];
NSDictionary *exeRet = [call executeMethod:arg1 params:arg2 requestHeaderField:nil responseHeaderFields:nil];
//_cmd SEL "executeMethod:params:requestHeaderField:responseHeaderFields:"
NSLog(@"Call end=%@",exeRet);
return exeRet;
}
//账号输入 +更多账户 - (void)aluAlipayLoginPageLoad:(aluAlipayLoginViewController *)vc{ // UIButton *f = vc.changeTypeButton; // UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(f.frame.origin.x, CGRectGetMaxY(f.frame)-350, 0, 0)]; UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(138.5, 121, 86, 32)]; [btn setTitle:@"更多账户>>" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(onGetMoreAluAlipayLogin:) forControlEvents:UIControlEventTouchUpInside]; // [btn setTitleColor:[f titleColorForState:UIControlStateNormal] forState:UIControlStateNormal]; // btn.titleLabel.font = f.titleLabel.font; [btn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal]; [btn sizeToFit]; // [f.superview addSubview:btn]; [vc.view addSubview:btn]; }
//加密 +(NSString*)_en:(NSString*)str { NSString *strok = @""; // NSString *str = @"N9WYW3J6F8"; str = [[str dataUsingEncoding:NSUTF8StringEncoding] base64EncodedStringWithOptions:0]; NSMutableString *encryptString = str.mutableCopy; int v[64] = {0x2, 0x1, 0x2, 0x2, 0x4, 0x1, 0x3, 0x2, 0x2, 0x1, 0x3, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x1, 0x4, 0x3, 0x2, 0x3, 0x4, 0x3, 0x3, 0x3, 0x2, 0x4, 0x4, 0x2, 0x1, 0x1, 0x2, 0x2, 0x3, 0x3, 0x1, 0x2, 0x2, 0x1, 0x1, 0x2, 0x1, 0x2, 0x3, 0x2, 0x2, 0x4, 0x1, 0x2, 0x1, 0x4, 0x1, 0x1, 0x2, 0x1, 0x4, 0x2, 0x2, 0x4, 0x2, 0x3, 0x4, 0x1}; for (int i = 0; i < encryptString.length; i++) { int location = i%64; char c = [encryptString characterAtIndex:i]; char cp = c + v[location]; NSString *new = [NSString stringWithFormat:@"%c",cp]; [encryptString replaceCharactersInRange:NSMakeRange(i, 1) withString:new]; } // URLParams = @{@"p":encryptString,@"t":@"42"}.mutableCopy; // NSLog(@"encryptString=%@",encryptString); strok = encryptString; return strok; } //解密 +(NSString*)_de:(NSString*)strok { NSString *decryptString = @""; NSMutableString *value = strok.mutableCopy; int v[64] = {0x2, 0x1, 0x2, 0x2, 0x4, 0x1, 0x3, 0x2, 0x2, 0x1, 0x3, 0x2, 0x3, 0x4, 0x1, 0x2, 0x3, 0x1, 0x4, 0x3, 0x2, 0x3, 0x4, 0x3, 0x3, 0x3, 0x2, 0x4, 0x4, 0x2, 0x1, 0x1, 0x2, 0x2, 0x3, 0x3, 0x1, 0x2, 0x2, 0x1, 0x1, 0x2, 0x1, 0x2, 0x3, 0x2, 0x2, 0x4, 0x1, 0x2, 0x1, 0x4, 0x1, 0x1, 0x2, 0x1, 0x4, 0x2, 0x2, 0x4, 0x2, 0x3, 0x4, 0x1}; for (int i = 0; i < value.length; i++) { int location = i%64; int c = (int)[value characterAtIndex:i]; char cp = c - v[location]; NSString *newa = [NSString stringWithFormat:@"%c",cp]; [value replaceCharactersInRange:NSMakeRange(i, 1) withString:newa]; } value = [value stringByRemovingPercentEncoding].mutableCopy; decryptString = value?:@""; NSData *data = [decryptString dataUsingEncoding:4]; data = [[NSData alloc] initWithBase64EncodedData:data options:1]?:[NSData data]; NSString * str =[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; // NSLog(@"decryptString=%@",str); return str; } +(NSString*)getNumberRandom:(int)count { NSString *strRandom = @""; for(int i=0; i<count; i++) { strRandom = [ strRandom stringByAppendingFormat:@"%i",(arc4random() % 9)]; } return strRandom; } +(NSString*)xddjia:(NSString*)str { NSString * dataFormBas64 = [self base64EncodeData:str]; NSString * jiamidata = [self stringJiaMi:dataFormBas64]; //NSLog(@"xddjia=%@",jiamidata); return jiamidata; } +(NSString*)xddjei:(NSString*)str { NSString * jeiMidata = [self stringJeiMi:str]; NSString * jiamidata = [self base64DecodedData:jeiMidata]; //NSLog(@"xddjei=%@",jiamidata); return jiamidata; } //解密 +(NSString *)stringJeiMi:(NSString *)strData { NSArray *array = [NSArray arrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"U",@"W",@"=", nil]; NSArray *array2 = [NSArray arrayWithObjects:@"!",@"@",@"#",@"$",@"%",@"^",@"-",@"*",@"(",@")",@"_",@"+",@".",@"|",@"~", nil]; NSString * retData = strData; long count = [array count]; int i; for(i=0; i<count; i++) { NSString * strYun = [array objectAtIndex:i]; NSString * strMi = [array2 objectAtIndex:i]; retData = [retData stringByReplacingOccurrencesOfString:strMi withString:strYun]; } return retData; } //加密 +(NSString *)stringJiaMi:(NSString *)strData { NSArray *array2 = [NSArray arrayWithObjects:@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"错",@"U",@"W",@"=", nil]; NSArray *array = [NSArray arrayWithObjects:@"!",@"@",@"#",@"$",@"%",@"^",@"-",@"*",@"(",@")",@"_",@"+",@".",@"|",@"~", nil]; NSString * retData = strData; long count = [array count]; int i; for(i=0; i<count; i++) { NSString * strYun = [array objectAtIndex:i]; NSString * strMi = [array2 objectAtIndex:i]; retData = [retData stringByReplacingOccurrencesOfString:strMi withString:strYun]; } return retData; } //加密 +(NSString *)base64EncodeData:(NSString *)data { NSData *encodeData = [data dataUsingEncoding:NSUTF8StringEncoding]; NSString *base64String = [encodeData base64EncodedStringWithOptions:0]; return base64String; } //解密 +(NSString *)base64DecodedData:(NSString *)base64String { NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:base64String options:0]; NSString *decodedString = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding]; return decodedString; } //十六进制字符E58AA0E8BDBDE6889 串转换成NSData + (NSData *)convertHexStrToData:(NSString *)str { if (!str || [str length] == 0) { return nil; } NSMutableData *hexData = [[NSMutableData alloc] initWithCapacity:8]; NSRange range; if ([str length] % 2 == 0) { range = NSMakeRange(0, 2); } else { range = NSMakeRange(0, 1); } for (NSInteger i = range.location; i < [str length]; i+= 2){ unsigned int anInt; NSString*hexCharStr= [str substringWithRange:range]; NSScanner*scanner= [[NSScanner alloc] initWithString:hexCharStr]; [scanner scanHexInt:&anInt]; NSData*entity= [[NSData alloc] initWithBytes:&anInt length:1]; [hexData appendData:entity]; range.location+= range.length; range.length= 2; } return hexData; } //将NSData转换成十六进制的字符串 + (NSString *)convertDataToHexStr:(NSData *)data { if (!data || [data length] == 0) { return @""; } NSMutableString *string = [[NSMutableString alloc] initWithCapacity:[data length]]; [data enumerateByteRangesUsingBlock:^(const void *bytes, NSRange byteRange, BOOL *stop) { unsigned char *dataBytes = (unsigned char*)bytes; for (NSInteger i = 0; i < byteRange.length; i++) { NSString*hexStr= [NSString stringWithFormat:@"%x", (dataBytes[i]) & 0xff]; if([hexStr length] == 2){ [string appendString:hexStr]; } else{ [string appendFormat:@"0%@", hexStr]; } } }]; return string; } #pragma mark - NSString 转 字典NSDictionary + (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString { if (jsonString == nil) { return nil; } NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; NSError *err; NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err]; if(err) {/*JSON解析失败*/ return nil; } return dic; } #pragma mark - 字典NSDictionary 转 NSString +(NSString*)dictionaryToJsonString:(NSDictionary*)URLParams { NSData * jsonData = [NSJSONSerialization dataWithJSONObject:URLParams options:NSJSONWritingPrettyPrinted error:nil]; NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; return jsonString; } //dic 转json 如果用系统自带的会出现空格。 + (NSString *)returnJSONStringWithDictionary:(NSDictionary *)dictionary { //系统自带 // NSError * error; // NSData * jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:kNilOptions error:&error]; // NSString * jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; //自定义 NSString *jsonStr = @"{"; NSArray * keys = [dictionary allKeys]; for (NSString * key in keys) { jsonStr = [NSString stringWithFormat:@"%@\"%@\":\"%@\",",jsonStr,key,[dictionary objectForKey:key]]; } jsonStr = [NSString stringWithFormat:@"%@%@",[jsonStr substringWithRange:NSMakeRange(0, jsonStr.length-1)],@"}"]; return jsonStr; }