【iOS逆向与安全】DTRpcClient 抓包和代码分析记录

news2024/11/28 2:31:30

 


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-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Jza2RrS01IZThONnFIYW51Z0NVRFNxT2VsWklSRG5sUkd6Smh3RVRESzBcL2FoZXJpQjYyQ0hoa2FXY2FXcE1WcDhvaDFwVUgrcitZbXBCNG5RYVlJUlwvdlNucW82MldpNzRNPSIsImRldktleVNldCI6eyJhcGRpZFRva2VuIjoiS2VzRGc2bU5pWXVBXC9zbGlac2h5UUE5V2tcL2l2TklrcFJEWjhCdjQ3eWRGaGwxM2N3UStDZUFFQiJ9fcoCGAoMdGVybWluYWxOYW1lEghpUGhvbmUgWMoCHAoOcHJvZHVjdFZlcnNpb24SCjMuMTQuMC4zNTDKAhgKBXZpbWVpEg9zZ3Myamtzc3BkcWwzcm3SAg8KB25ldFR5cGUSBFdXQU7SAi4KFGFmdGVyTG9naW5TeW5jQ29uZmlnEhZ7ICAiZmFjZVN0YXR1cyIgOiAiTiJ90gKgAQoDbGRmEpgBTVlGS0NvNlRwUWV4VjBwNlZacDY3RllzeTFWTTUwV0J3ZVNxWkZXdldUOFJWQjUwb0lSWGJza2RrS01IZThONnFIYW51Z0NVRFNxT2VsWklSRG5sUkd6Smh3RVRESzAvYWhlcmlCNjJDSGhrYVdjYVdwTVZwOG9oMXBVSCtyK1ltcEI0blFhWUlSL3ZTbnFvNjJXaTc0TT3SAhMKDmFwZGlkRG93bmdyYWRlEgFO0gI4CghlZGdlRGF0YRIsS0o1c2VvMmVBNm9HYUozQkFNUGFXaFlRT0Q1dDZSNjNoTFdHQ01kaVc4Yz3SAlgKCWRldktleVNldBJLeyJhcGRpZFRva2VuIjoiS2VzRGc2bU5pWXVBXC9zbGlac2h5UUE5V2tcL2l2TklrcFJEWjhCdjQ3eWRGaGwxM2N3UStDZUFFQiJ92gIHMi4wLjAuNA==&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;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1042108.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【SpringBoot】| SpringBoot集成Dubbo

目录 一&#xff1a;SpringBoot集成Dubbo 1. 创建公共项目 2. 创建提供者项目provider 3. 创建消费者consumer项目 4. 注册中心Zookeeper的安装 图书推荐&#xff1a;《Python 自动化办公应用大全》 一&#xff1a;SpringBoot集成Dubbo 阿里巴巴提供了 dubbo 集成 spring…

原来,这就是现货黄金投资最大的悲哀

在现货黄金投资之中&#xff0c;最大的悲哀是什么呢&#xff1f;首先要知道的是现货黄金投资中最大的悲哀并不是亏损&#xff0c;比如投资者会问我都亏损了&#xff0c;为什么不是最大的悲&#xff1f;哎&#xff0c;不就是因为想进行现货黄金投资&#xff0c;就是想获利的吗&a…

北斗导航系统为渔船保驾护航,助力海洋渔业发展

在无垠的海洋中&#xff0c;渔船扮演着举足轻重的角色&#xff0c;为人们带来美味的海鲜。然而&#xff0c;每一次渔船出海都充满了未知和危险&#xff0c;船只的安全成为了渔民和国家关注的焦点。幸运的是&#xff0c;北斗导航系统作为一项顶级技术正在为渔船保驾护航&#xf…

肖sir___环境的讲解详情__002

一、环境讲解 1、jdk 什么是JDK&#xff1f;JDK的作用&#xff1f; JDK是java语言的软件开发工具包&#xff0c;能解释java程序&#xff0c;编译java语言&#xff0c;没有jdk的话无法编译Java程序。 包含了各种类库和工具&#xff0c;机器不是直接识别语言的&#xff0c;会借助…

零信任沙盒

零信任沙盒分析对比 互联网早期的沙盒&#xff08;sandbox&#xff09;又译为沙箱&#xff0c;意为在计算机安全领域中构建一种安全机制&#xff0c;为运行中的程序提供的隔离环境。通常用来测试一些来源不可信、具破坏力或无法判定的程序&#xff0c;特别是病毒木马类的程序。…

塔望食研院|千亿食用油市场拐点,量减价增,竞争加剧!

自2022年12月塔望咨询开设塔望食品大健康消费研究院&#xff08;简称塔望食研院&#xff09;栏目以来&#xff0c;塔望食研院以“为食品行业品牌高质量发展赋能”为理念&#xff0c;不断发布食品大健康行业研究、消费研究报告。塔望食研院致力于结合消费调研数据、企业数据、第…

XC8233 电容式单按键触摸检测 IC 广泛应用于 TWS及 DC 应用上,实现产品智能化

目前市面上很多的小家电和消费类电子都已经改成触摸式的按键功能&#xff0c;而XC8233是一款电容式单按键触摸检测及接近感应控制芯片。采用 CMOS 工艺制造&#xff0c;内建稳压和去抖动电路&#xff0c;高可靠性&#xff0c;专为取代传统按键开关而设计。超低功耗与宽工作电压…

Java笔记:手写spring之简单实现springboot

手写spring之简单实现springboot 仓库地址: Raray-chuan/mini-spring 博文列表: 导读手写spring之ioc手写spring之aop手写spring之简单实现springboot 1.springmvc框架的理解 什么是MVC: MVC就是一个分层架构模式: MVC 设计模式一般指 MVC 框架&#xff0c;M&#xff08…

ALM物联网管理平台助力中台上云 数字化转型让展示更直观清晰

支持移动浏览、支持大屏显示等功能&#xff0c;能够为设备厂家提供数据依据&#xff0c;方便厂家的售后以及产品的维护、为运维等相关公司提供运维管理等相关功能。 ALM物联网云平台是基于以往的物联网产品&#xff0c;以及目前市场上的各种云平台优点&#xff0c;研精心打造的…

车联网安全集智联盟正式成立

2023年9月22日&#xff0c;在工业和信息化部网络安全管理局支持下&#xff0c;2023年世界智能网联汽车大会——“集智创新车联网安全新格局”特色专场在北京举行。工业和信息化部网络安全管理局领导出席并致辞&#xff0c;中国工程院邬江兴院士以及来自政产学研用等各方的领导和…

TLS/SSL(一)科普之加密、签名和SSL握手

一 背景知识 感悟&#xff1a; 不能高不成低不就备注&#xff1a; 以下内容没有逻辑排版,仅做记录 https基础面经 ① 加密方式 说明&#xff1a; 单向和双向认证遗留&#xff1a; 如何用openssl从私钥中提取公钥? ② 互联网数据安全可靠条件 说明&#xff1a; 二者相…

Java核心-你真的知道Object吗(Object:所有类的超类)

作者&#xff1a;逍遥Sean 简介&#xff1a;一个主修Java的Web网站\游戏服务器后端开发者 主页&#xff1a;https://blog.csdn.net/Ureliable 觉得博主文章不错的话&#xff0c;可以三连支持一下~ 如有需要我的支持&#xff0c;请私信或评论留言&#xff01; 前言 今天来聊一聊…

医院陪诊小程序源码 陪诊陪护小程序源码

医院陪诊小程序源码 陪诊陪护小程序源码 近年来&#xff0c;随着互联网技术的不断发展&#xff0c;我们的生活中出现了越来越多的智能设备和智能应用&#xff0c;这些智能应用不仅极大方便了我们的生活&#xff0c;还对现代医疗服务体验产生了深远的影响。本文将为大家介绍一种…

轻松搭建Linux的环境

Linux的环境的搭建 目录&#xff1a;一、使用云服务器二、使用虚拟机软件2.1 下载虚拟机软件2.2 下载一个操作系统的镜像文件 三、直接安装在物理机上四、使用XShell远程登录到Linux 目录&#xff1a; 我们平常用的都是windows系统&#xff0c;对Linux系统还是很陌生得。为什么…

【软件测试】资深测试聊,自动化测试分层实践,彻底打通高阶...

目录&#xff1a;导读 前言一、Python编程入门到精通二、接口自动化项目实战三、Web自动化项目实战四、App自动化项目实战五、一线大厂简历六、测试开发DevOps体系七、常用自动化测试工具八、JMeter性能测试九、总结&#xff08;尾部小惊喜&#xff09; 前言 自动化测试的分层…

软件调研、研发、设计、管理、验收文档(全文档整理)

前言&#xff1a; 在软件开发生命周期中&#xff0c;调研、研发、设计、管理、验收等环节的文档编写至关重要。它们分别扮演着不同的角色&#xff0c;为项目的顺利进行和最终的成功提供支持和保障。 【获取方式在文末】 【在调研阶段】&#xff0c;文档的主要作用是记录和整…

Java环形链表(图文详解)

目录 一、判断链表中是否有环 &#xff08;1&#xff09;题目描述 &#xff08;2&#xff09;题解 二、环形链表的入环节点 &#xff08;1&#xff09;题目描述 &#xff08;2&#xff09;题解 一、判断链表中是否有环 &#xff08;1&#xff09;题目描述 给你一个链表的…

OCX 添加方法和事件 HTML调用ocx函数及回调 ocx又调用dll VS2017

ocx添加方法 类视图 最后面的XXXXXlib 右键 添加 添加方法。 其它默认 添加事件 类视图 最后面的XXXXX 右键 添加 添加事件。 这样编译就ocx可以了。 #include <iostream> #include <string> #include <comutil.h>CMFCActiveXControlSmartPosCtrl* …

Linux内核启动流程-第二阶段rest_init函数

一. Linux内核启动 上一篇文章简单了解了 Linux内核启动第二阶段&#xff0c;涉及的 start_kernel函数。start_kernel 函数最后调用了 rest_init 函数&#xff0c;接下来简单看一下 rest_init 函数。 本文续上一篇文章的学习&#xff0c;地址如下&#xff1a; Linux内核启…

W5500+树莓派RP2040入门教程之MQTT篇(十二)

目录 1 前言 2 什么是MQTT协议&#xff1f; 2.1 特点 2.2 应用 2.3 身份 2.4 消息质量等级 2.5 遗嘱消息 3 硬件介绍 4 硬件接线 5 代码编写 6 移植说明 7 最终现象 8 总结 9 项目链接 1 前言 随着物联网技术的快速发展&#xff0c;MQTT&#xff08;Message Queuing Telemetry …