openlockPPP 10 months ago
parent
commit
788697ad02
30 changed files with 0 additions and 1980 deletions
  1. BIN
      jiaPei.xcworkspace/xcuserdata/mimasigeling.xcuserdatad/UserInterfaceState.xcuserstate
  2. 0 19
      jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayPriceHeaderGroupViewModel.h
  3. 0 24
      jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayPriceHeaderGroupViewModel.m
  4. 0 17
      jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayTypeItemViewModel.h
  5. 0 13
      jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayTypeItemViewModel.m
  6. 0 79
      jiaPei/OLD/Util/Pay/Order.h
  7. 0 65
      jiaPei/OLD/Util/Pay/Order.m
  8. 0 25
      jiaPei/OLD/Util/Pay/Util/DataSigner.h
  9. 0 17
      jiaPei/OLD/Util/Pay/Util/DataSigner.m
  10. 0 20
      jiaPei/OLD/Util/Pay/Util/DataVerifier.h
  11. 0 18
      jiaPei/OLD/Util/Pay/Util/DataVerifier.m
  12. 0 15
      jiaPei/OLD/Util/Pay/Util/MD5DataSigner.h
  13. 0 22
      jiaPei/OLD/Util/Pay/Util/MD5DataSigner.m
  14. 0 20
      jiaPei/OLD/Util/Pay/Util/NSDataEx.h
  15. 0 187
      jiaPei/OLD/Util/Pay/Util/NSDataEx.m
  16. 0 18
      jiaPei/OLD/Util/Pay/Util/RSADataSigner.h
  17. 0 91
      jiaPei/OLD/Util/Pay/Util/RSADataSigner.m
  18. 0 18
      jiaPei/OLD/Util/Pay/Util/RSADataVerifier.h
  19. 0 80
      jiaPei/OLD/Util/Pay/Util/RSADataVerifier.m
  20. 0 70
      jiaPei/OLD/Util/Pay/Util/base64.h
  21. 0 211
      jiaPei/OLD/Util/Pay/Util/base64.m
  22. 0 285
      jiaPei/OLD/Util/Pay/Util/config.h
  23. 0 20
      jiaPei/OLD/Util/Pay/Util/openssl_wrapper.h
  24. 0 175
      jiaPei/OLD/Util/Pay/Util/openssl_wrapper.m
  25. 0 31
      jiaPei/OLD/Util/WXPay/ApiXml.h
  26. 0 53
      jiaPei/OLD/Util/WXPay/ApiXml.mm
  27. 0 18
      jiaPei/OLD/Util/WXPay/WXUtil.h
  28. 0 66
      jiaPei/OLD/Util/WXPay/WXUtil.mm
  29. 0 86
      jiaPei/OLD/Util/WXPay/payRequsestHandler.h
  30. 0 217
      jiaPei/OLD/Util/WXPay/payRequsestHandler.mm

BIN
jiaPei.xcworkspace/xcuserdata/mimasigeling.xcuserdatad/UserInterfaceState.xcuserstate


+ 0 - 19
jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayPriceHeaderGroupViewModel.h

@@ -1,19 +0,0 @@
-//
-//  RQPayPriceHeaderGroupViewModel.h
-//  jiaPei
-//
-//  Created by 张嵘 on 2022/6/7.
-//  Copyright © 2022 JCZ. All rights reserved.
-//
-
-#import "RQCommonGroupViewModel.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface RQPayPriceHeaderGroupViewModel : RQCommonGroupViewModel
-@property (nonatomic, readonly, strong) RQTypeModel *typeModel;
-/// init
-- (instancetype)initWithRQTypeModel:(RQTypeModel *)typeModel;
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 24
jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayPriceHeaderGroupViewModel.m

@@ -1,24 +0,0 @@
-//
-//  RQPayPriceHeaderGroupViewModel.m
-//  jiaPei
-//
-//  Created by 张嵘 on 2022/6/7.
-//  Copyright © 2022 JCZ. All rights reserved.
-//
-
-#import "RQPayPriceHeaderGroupViewModel.h"
-
-@interface RQPayPriceHeaderGroupViewModel ()
-@property (nonatomic, readwrite, strong) RQTypeModel *typeModel;
-@end
-
-@implementation RQPayPriceHeaderGroupViewModel
-/// init
-- (instancetype)initWithRQTypeModel:(RQTypeModel *)typeModel {
-    if (self = [super init]) {
-        self.typeModel = typeModel;
-        self.headerHeight = RQ_FIT_HORIZONTAL(86.f);
-    }
-    return self;
-}
-@end

+ 0 - 17
jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayTypeItemViewModel.h

@@ -1,17 +0,0 @@
-//
-//  RQPayTypeItemViewModel.h
-//  jiaPei
-//
-//  Created by 张嵘 on 2022/6/9.
-//  Copyright © 2022 JCZ. All rights reserved.
-//
-
-#import "RQCommonItemViewModel.h"
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface RQPayTypeItemViewModel : RQCommonItemViewModel
-@property (nonatomic, readwrite, assign) NSInteger selectedItemIndex;
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 13
jiaPei/Modules/OtherModules/VIPModule/ViewModel/itemViewModel/支付/RQPayTypeItemViewModel.m

@@ -1,13 +0,0 @@
-//
-//  RQPayTypeItemViewModel.m
-//  jiaPei
-//
-//  Created by 张嵘 on 2022/6/9.
-//  Copyright © 2022 JCZ. All rights reserved.
-//
-
-#import "RQPayTypeItemViewModel.h"
-
-@implementation RQPayTypeItemViewModel
-
-@end

+ 0 - 79
jiaPei/OLD/Util/Pay/Order.h

@@ -1,79 +0,0 @@
-//
-//  Order.h
-//  AlixPayDemo
-//
-//  Created by 方彬 on 11/2/13.
-//
-//
-
-#import <Foundation/Foundation.h>
-
-@interface Order : NSObject
-
-
-/*********************************支付四要素*********************************/
-
-//商户在支付宝签约时,支付宝为商户分配的唯一标识号(以2088开头的16位纯数字)。
-@property (nonatomic, copy) NSString *partner;
-
-//卖家支付宝账号对应的支付宝唯一用户号(以2088开头的16位纯数字),订单支付金额将打入该账户,一个partner可以对应多个seller_id。
-@property (nonatomic, copy) NSString *sellerID;
-
-//商户网站商品对应的唯一订单号。
-@property (nonatomic, copy) NSString *outTradeNO;
-
-//该笔订单的资金总额,单位为RMB(Yuan)。取值范围为[0.01,100000000.00],精确到小数点后两位。
-@property (nonatomic, copy) NSString *totalFee;
-
-
-
-/*********************************商品相关*********************************/
-//商品的标题/交易标题/订单标题/订单关键字等。
-@property (nonatomic, copy) NSString *subject;
-
-//对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body。
-@property (nonatomic, copy) NSString *body;
-
-
-
-/*********************************其他必传参数*********************************/
-
-//接口名称,固定为mobile.securitypay.pay。
-@property (nonatomic, copy) NSString *service;
-
-//商户网站使用的编码格式,固定为utf-8。
-@property (nonatomic, copy) NSString *inputCharset;
-
-//支付宝服务器主动通知商户网站里指定的页面http路径。
-@property (nonatomic, copy) NSString *notifyURL;
-
-
-
-/*********************************可选参数*********************************/
-
-//支付类型,1:商品购买。(不传情况下的默认值)
-@property (nonatomic, copy) NSString *paymentType;
-
-//具体区分本地交易的商品类型,1:实物交易; (不传情况下的默认值),0:虚拟交易; (不允许使用信用卡等规则)。
-@property (nonatomic, copy) NSString *goodsType;
-
-//支付时是否发起实名校验,F:不发起实名校验; (不传情况下的默认值),T:发起实名校验;(商户业务需要买家实名认证)
-@property (nonatomic, copy) NSString *rnCheck;
-
-//标识客户端。
-@property (nonatomic, copy) NSString *appID;
-
-//标识客户端来源。参数值内容约定如下:appenv=“system=客户端平台名^version=业务系统版本”
-@property (nonatomic, copy) NSString *appenv;
-
-//设置未付款交易的超时时间,一旦超时,该笔交易就会自动被关闭。当用户输入支付密码、点击确认付款后(即创建支付宝交易后)开始计时。取值范围:1m~15d,或者使用绝对时间(示例格式:2014-06-13 16:00:00)。m-分钟,h-小时,d-天,1c-当天(1c-当天的情况下,无论交易何时创建,都在0点关闭)。该参数数值不接受小数点,如1.5h,可转换为90m。
-@property (nonatomic, copy) NSString *itBPay;
-
-//商品地址
-@property (nonatomic, copy) NSString *showURL;
-
-//业务扩展参数,支付宝特定的业务需要添加该字段,json格式。 商户接入时和支付宝协商确定。
-@property (nonatomic, strong) NSMutableDictionary *outContext;
-
-
-@end

+ 0 - 65
jiaPei/OLD/Util/Pay/Order.m

@@ -1,65 +0,0 @@
-//
-//  Order.m
-//  AlixPayDemo
-//
-//  Created by 方彬 on 11/2/13.
-//
-//
-
-#import "Order.h"
-
-@implementation Order
-
-- (NSString *)description {
-    NSMutableString * discription = [NSMutableString string];
-    if (self.partner) {
-        [discription appendFormat:@"partner=\"%@\"", self.partner];
-    }
-    
-    if (self.sellerID) {
-        [discription appendFormat:@"&seller_id=\"%@\"", self.sellerID];
-    }
-    if (self.outTradeNO) {
-        [discription appendFormat:@"&out_trade_no=\"%@\"", self.outTradeNO];
-    }
-    if (self.subject) {
-        [discription appendFormat:@"&subject=\"%@\"", self.subject];
-    }
-    
-    if (self.body) {
-        [discription appendFormat:@"&body=\"%@\"", self.body];
-    }
-    if (self.totalFee) {
-        [discription appendFormat:@"&total_fee=\"%@\"", self.totalFee];
-    }
-    if (self.notifyURL) {
-        [discription appendFormat:@"&notify_url=\"%@\"", self.notifyURL];
-    }
-    
-    if (self.service) {
-        [discription appendFormat:@"&service=\"%@\"",self.service];//mobile.securitypay.pay
-    }
-    if (self.paymentType) {
-        [discription appendFormat:@"&payment_type=\"%@\"",self.paymentType];//1
-    }
-    
-    if (self.inputCharset) {
-        [discription appendFormat:@"&_input_charset=\"%@\"",self.inputCharset];//utf-8
-    }
-    if (self.itBPay) {
-        [discription appendFormat:@"&it_b_pay=\"%@\"",self.itBPay];//30m
-    }
-    if (self.showURL) {
-        [discription appendFormat:@"&show_url=\"%@\"",self.showURL];//m.alipay.com
-    }
-    if (self.appID) {
-        [discription appendFormat:@"&app_id=\"%@\"",self.appID];
-    }
-    for (NSString * key in [self.outContext allKeys]) {
-        [discription appendFormat:@"&%@=\"%@\"", key, [self.outContext objectForKey:key]];
-    }
-    return discription;
-}
-
-
-@end

+ 0 - 25
jiaPei/OLD/Util/Pay/Util/DataSigner.h

@@ -1,25 +0,0 @@
-//
-//  DataSigner.h
-//  AlixPayDemo
-//
-//  Created by Jing Wen on 8/2/11.
-//  Copyright 2011 alipay.com. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-
-typedef enum DataSignAlgorithm {
-	DataSignAlgorithmRSA,
-	DataSignAlgorithmMD5,
-} DataSignAlgorithm;
-
-@protocol DataSigner
-
-- (NSString *)algorithmName;
-- (NSString *)signString:(NSString *)string;
-
-@end
-
-id<DataSigner> CreateRSADataSigner(NSString *privateKey);
-

+ 0 - 17
jiaPei/OLD/Util/Pay/Util/DataSigner.m

@@ -1,17 +0,0 @@
-//
-//  DataSigner.m
-//  AlixPayDemo
-//
-//  Created by Jing Wen on 8/2/11.
-//  Copyright 2011 alipay.com. All rights reserved.
-//
-
-#import "DataSigner.h"
-#import "RSADataSigner.h"
-#import "MD5DataSigner.h"
-
-id<DataSigner> CreateRSADataSigner(NSString *privateKey) {
-	
-	return [[RSADataSigner alloc] initWithPrivateKey:privateKey];
-	
-}

+ 0 - 20
jiaPei/OLD/Util/Pay/Util/DataVerifier.h

@@ -1,20 +0,0 @@
-//
-//  DataVerifier.h
-//  AlixPayDemo
-//
-//  Created by Jing Wen on 8/2/11.
-//  Copyright 2011 alipay.com. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-
-@protocol DataVerifier
-
-- (NSString *)algorithmName;
-- (BOOL)verifyString:(NSString *)string withSign:(NSString *)signString;
-
-@end
-
-id<DataVerifier> CreateRSADataVerifier(NSString *publicKey);
-

+ 0 - 18
jiaPei/OLD/Util/Pay/Util/DataVerifier.m

@@ -1,18 +0,0 @@
-//
-//  DataVerifier.m
-//  AlixPayDemo
-//
-//  Created by Jing Wen on 8/2/11.
-//  Copyright 2011 alipay.com. All rights reserved.
-//
-
-#import "DataVerifier.h"
-
-
-#import "RSADataVerifier.h"
-
-id<DataVerifier> CreateRSADataVerifier(NSString *publicKey) {
-	
-	return [[RSADataVerifier alloc] initWithPublicKey:publicKey];
-	
-}

+ 0 - 15
jiaPei/OLD/Util/Pay/Util/MD5DataSigner.h

@@ -1,15 +0,0 @@
-//
-//  MD5DataSigner.h
-//  SafepayService
-//
-//  Created by wenbi on 11-4-11.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-#import "DataSigner.h"
-
-@interface MD5DataSigner : NSObject <DataSigner> {
-}
-
-@end

+ 0 - 22
jiaPei/OLD/Util/Pay/Util/MD5DataSigner.m

@@ -1,22 +0,0 @@
-//
-//  MD5DataSigner.m
-//  SafepayService
-//
-//  Created by wenbi on 11-4-11.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import "MD5DataSigner.h"
-
-
-@implementation MD5DataSigner
-
-- (NSString *)algorithmName {
-	return @"MD5";
-}
-
-- (NSString *)signString:(NSString *)string {
-	return @"";
-}
-
-@end

+ 0 - 20
jiaPei/OLD/Util/Pay/Util/NSDataEx.h

@@ -1,20 +0,0 @@
-//
-//  NSDataEx.h
-//  iX3.0
-//
-//  Created by Feng Huajun on 09-4-16.
-//  Copyright 2009 Infothinker. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-
-@interface NSData (NSDataBase64Additions)
-+ (NSData *) dataWithBase64EncodedString:(NSString *) string;
-- (id) initWithBase64EncodedString:(NSString *) string;
-
-- (NSString *) base64Encoding;
-- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength;
-//- (NSString*) urlEncodedString;
-
-@end

+ 0 - 187
jiaPei/OLD/Util/Pay/Util/NSDataEx.m

@@ -1,187 +0,0 @@
-//
-//  NSDataEx.m
-//  iX3.0
-//
-//  Created by Feng Huajun on 09-4-16.
-//  Copyright 2009 Infothinker. All rights reserved.
-//
-
-#import "NSDataEx.h"
-
-static char encodingTable[64] = {
-'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
-'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
-'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
-'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' };
-
-@implementation NSData (NSDataBase64Additions)
-
-+ (NSData *) dataWithBase64EncodedString:(NSString *) string {
-    NSData *result = [[NSData alloc] initWithBase64EncodedString:string];
-    return result;
-}
-
-- (id) initWithBase64EncodedString:(NSString *) string {
-    NSMutableData *mutableData = nil;
-    
-    if( string ) {
-        unsigned long ixtext = 0;
-        unsigned long lentext = 0;
-        unsigned char ch = 0;
-        unsigned char inbuf[4], outbuf[3];
-        short i = 0, ixinbuf = 0;
-        BOOL flignore = NO;
-        BOOL flendtext = NO;
-        NSData *base64Data = nil;
-        const unsigned char *base64Bytes = nil;
-        
-        // Convert the string to ASCII data.
-        base64Data = [string dataUsingEncoding:NSASCIIStringEncoding];
-        base64Bytes = [base64Data bytes];
-        mutableData = [NSMutableData dataWithCapacity:[base64Data length]];
-        lentext = [base64Data length];
-        
-        while( YES ) {
-            if( ixtext >= lentext ) break;
-            ch = base64Bytes[ixtext++];
-            flignore = NO;
-            
-            if( ( ch >= 'A' ) && ( ch <= 'Z' ) ) ch = ch - 'A';
-            else if( ( ch >= 'a' ) && ( ch <= 'z' ) ) ch = ch - 'a' + 26;
-            else if( ( ch >= '0' ) && ( ch <= '9' ) ) ch = ch - '0' + 52;
-            else if( ch == '+' ) ch = 62;
-            else if( ch == '=' ) flendtext = YES;
-            else if( ch == '/' ) ch = 63;
-            else flignore = YES; 
-            
-            if( ! flignore ) {
-                short ctcharsinbuf = 3;
-                BOOL flbreak = NO;
-                
-                if( flendtext ) {
-                    if( ! ixinbuf ) break;
-                    if( ( ixinbuf == 1 ) || ( ixinbuf == 2 ) ) ctcharsinbuf = 1;
-                    else ctcharsinbuf = 2;
-                    ixinbuf = 3;
-                    flbreak = YES;
-                }
-                
-                inbuf [ixinbuf++] = ch;
-                
-                if( ixinbuf == 4 ) {
-                    ixinbuf = 0;
-                    outbuf [0] = ( inbuf[0] << 2 ) | ( ( inbuf[1] & 0x30) >> 4 );
-                    outbuf [1] = ( ( inbuf[1] & 0x0F ) << 4 ) | ( ( inbuf[2] & 0x3C ) >> 2 );
-                    outbuf [2] = ( ( inbuf[2] & 0x03 ) << 6 ) | ( inbuf[3] & 0x3F );
-                    
-                    for( i = 0; i < ctcharsinbuf; i++ ) 
-                        [mutableData appendBytes:&outbuf[i] length:1];
-                }
-                
-                if( flbreak )  break;
-            }
-        }
-    }
-    
-    self = [self initWithData:mutableData];
-    return self;
-}
-
-#pragma mark -
-
-- (NSString *) base64Encoding {
-    return [self base64EncodingWithLineLength:0];
-}
-
-- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength {
-    const unsigned char    *bytes = [self bytes];
-    NSMutableString *result = [NSMutableString stringWithCapacity:[self length]];
-    unsigned long ixtext = 0;
-    unsigned long lentext = [self length];
-    long ctremaining = 0;
-    unsigned char inbuf[3], outbuf[4];
-    short i = 0;
-    short charsonline = 0, ctcopy = 0;
-    unsigned long ix = 0;
-    
-    while( YES ) {
-        ctremaining = lentext - ixtext;
-        if( ctremaining <= 0 ) break;
-        
-        for( i = 0; i < 3; i++ ) {
-            ix = ixtext + i;
-            if( ix < lentext ) inbuf[i] = bytes[ix];
-            else inbuf [i] = 0;
-        }
-        
-        outbuf [0] = (inbuf [0] & 0xFC) >> 2;
-        outbuf [1] = ((inbuf [0] & 0x03) << 4) | ((inbuf [1] & 0xF0) >> 4);
-        outbuf [2] = ((inbuf [1] & 0x0F) << 2) | ((inbuf [2] & 0xC0) >> 6);
-        outbuf [3] = inbuf [2] & 0x3F;
-        ctcopy = 4;
-        
-        switch( ctremaining ) {
-            case 1: 
-                ctcopy = 2; 
-                break;
-            case 2: 
-                ctcopy = 3; 
-                break;
-        }
-        
-        for( i = 0; i < ctcopy; i++ )
-            [result appendFormat:@"%c", encodingTable[outbuf[i]]];
-        
-        for( i = ctcopy; i < 4; i++ )
-            [result appendFormat:@"%c",'='];
-        
-        ixtext += 3;
-        charsonline += 4;
-        
-        if( lineLength > 0 ) {
-            if (charsonline >= lineLength) {
-                charsonline = 0;
-                [result appendString:@"\n"];
-            }
-        }
-    }
-    
-    return result;
-}
-
-
-
-//- (NSString*) urlEncodedString
-//{
-//	char *hex = "0123456789ABCDEF";
-//	unsigned char* data = (unsigned char*)[self bytes];
-//	int len = [self length];
-//	//NSLog(@"len = %d", len);
-//	NSMutableString* s = [NSMutableString string];
-//	for(int i = 0;i<len;i++){
-//		unsigned char c = data[i];
-//		if( ('a' <= c && c <= 'z')
-//		   || ('A' <= c && c <= 'Z')
-//		   || ('0' <= c && c <= '9') ){
-//			NSString* ts = [[NSString alloc] initWithCString:(char *)&c length:1];
-//			
-//			[s appendString:ts];
-//			[ts release];
-//		} else {
-//			[s appendString:@"%"];
-//			char ts1 = hex[c >> 4];
-//		//	NSLog(@"ts = %c", ts1);
-//			NSString* ts = [[NSString alloc] initWithCString:&ts1 length:1];
-//			[s appendString:ts];
-//			[ts release];
-//			char ts2 = hex[c & 15];
-//			ts = [[NSString alloc] initWithCString:&ts2 length:1];
-//			[s appendString:ts];
-//			[ts release];
-//			
-//		}
-//	}
-//	return s;
-//}
-
-@end

+ 0 - 18
jiaPei/OLD/Util/Pay/Util/RSADataSigner.h

@@ -1,18 +0,0 @@
-//
-//  RSADataSigner.h
-//  SafepayService
-//
-//  Created by wenbi on 11-4-11.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-#import "DataSigner.h"
-
-@interface RSADataSigner : NSObject <DataSigner> {
-	NSString * _privateKey;
-}
-
-- (id)initWithPrivateKey:(NSString *)privateKey;
-
-@end

+ 0 - 91
jiaPei/OLD/Util/Pay/Util/RSADataSigner.m

@@ -1,91 +0,0 @@
-//
-//  RSADataSigner.m
-//  SafepayService
-//
-//  Created by wenbi on 11-4-11.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import "RSADataSigner.h"
-#import "openssl_wrapper.h"
-#import "NSDataEx.h"
-
-@implementation RSADataSigner
-
-- (id)initWithPrivateKey:(NSString *)privateKey {
-	if (self = [super init]) {
-		_privateKey = [privateKey copy];
-	}
-	return self;
-}
-
-- (NSString*)urlEncodedString:(NSString *)string {
-	NSString *charactersToEscape = @"!*'();:@&=+$,/?%#[]";
-	NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:charactersToEscape] invertedSet];
-	NSString *encodedString = [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
-    
-    return encodedString;
-}
-
-
-- (NSString *)formatPrivateKey:(NSString *)privateKey {
-    const char *pstr = [privateKey UTF8String];
-    int len = (int)[privateKey length];
-    NSMutableString *result = [NSMutableString string];
-    [result appendString:@"-----BEGIN RSA PRIVATE KEY-----\n"];
-    int index = 0;
-	int count = 0;
-    while (index < len) {
-        char ch = pstr[index];
-		if (ch == '\r' || ch == '\n') {
-			++index;
-			continue;
-		}
-        [result appendFormat:@"%c", ch];
-        if (++count == 79)
-        {
-            [result appendString:@"\n"];
-			count = 0;
-        }
-        index++;
-    }
-    [result appendString:@"\n-----END RSA PRIVATE KEY-----"];
-    return result;
-}
-
-- (NSString *)algorithmName {
-	return @"RSA";
-}
-
-//dansonmark
-//该签名方法仅供参考,外部商户可用自己方法替换
-- (NSString *)signString:(NSString *)string {
-	
-	//在Document文件夹下创建私钥文件
-	NSString * signedString = nil;
-	NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
-	NSString *path = [documentPath stringByAppendingPathComponent:@"AlixPay-RSAPrivateKey"];
-	
-	//
-	// 把密钥写入文件
-	//
-	NSString *formatKey = [self formatPrivateKey:_privateKey];
-	[formatKey writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
-	
-	const char *message = [string cStringUsingEncoding:NSUTF8StringEncoding];
-    int messageLength = (int)strlen(message);
-    unsigned char *sig = (unsigned char *)malloc(256);
-	unsigned int sig_len;
-    int ret = rsa_sign_with_private_key_pem((char *)message, messageLength, sig, &sig_len, (char *)[path UTF8String]);
-	//签名成功,需要给签名字符串base64编码和UrlEncode,该两个方法也可以根据情况替换为自己函数
-    if (ret == 1) {
-        NSString * base64String = base64StringFromData([NSData dataWithBytes:sig length:sig_len]);
-		//NSData * UTF8Data = [base64String dataUsingEncoding:NSUTF8StringEncoding];
-		signedString = [self urlEncodedString:base64String];
-    }
-	
-	free(sig);
-    return signedString;
-}
-
-@end

+ 0 - 18
jiaPei/OLD/Util/Pay/Util/RSADataVerifier.h

@@ -1,18 +0,0 @@
-//
-//  RSADataVerifier.h
-//  SafepayService
-//
-//  Created by wenbi on 11-4-11.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-#import "DataVerifier.h"
-
-@interface RSADataVerifier : NSObject <DataVerifier> {
-	NSString *_publicKey;
-}
-
-- (id)initWithPublicKey:(NSString *)publicKey;
-
-@end

+ 0 - 80
jiaPei/OLD/Util/Pay/Util/RSADataVerifier.m

@@ -1,80 +0,0 @@
-//
-//  AlixPayDataVerifier.m
-//  SafepayService
-//
-//  Created by wenbi on 11-4-11.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import "RSADataVerifier.h"
-#import "openssl_wrapper.h"
-#import "NSDataEx.h"
-#import "base64.h"
-
-@implementation RSADataVerifier
-
-- (id)initWithPublicKey:(NSString *)publicKey {
-	if (self = [super init]) {
-		_publicKey = [publicKey copy];
-	}
-	return self;
-}
-
-
-- (NSString *)formatPublicKey:(NSString *)publicKey {
-	
-	NSMutableString *result = [NSMutableString string];
-	
-	[result appendString:@"-----BEGIN PUBLIC KEY-----\n"];
-	
-	int count = 0;
-	
-	for (int i = 0; i < [publicKey length]; ++i) {
-		
-		unichar c = [publicKey characterAtIndex:i];
-		if (c == '\n' || c == '\r') {
-			continue;
-		}
-		[result appendFormat:@"%c", c];
-		if (++count == 76) {
-			[result appendString:@"\n"];
-			count = 0;
-		}
-		
-	}
-	
-	[result appendString:@"\n-----END PUBLIC KEY-----\n"];
-	
-	return result;
-	
-}
-
-- (NSString *)algorithmName {
-	return @"RSA";
-}
-
-- (BOOL)verifyString:(NSString *)string withSign:(NSString *)signString {
-	
-//	const char *message = [string cStringUsingEncoding:NSUTF8StringEncoding];
-//    int messageLength = strlen(message);
-//	
-//    unsigned char *signature = (unsigned char *)[signString UTF8String];
-//	unsigned int signatureLength = (unsigned int)strlen((char *)signature);
-//	char *encodedPath = (char *)[_pathForPEMFile cStringUsingEncoding:NSUTF8StringEncoding];
-
-	NSString *documentPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
-	NSString *path = [documentPath stringByAppendingPathComponent:@"AlixPay-RSAPublicKey"];
-	
-	//
-	// 把密钥写入文件
-	//
-	NSString *formatKey = [self formatPublicKey:_publicKey];
-	[formatKey writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
-	
-	BOOL ret;
-	rsaVerifyString(string, signString, path, &ret);
-	return ret;
-	
-}
-
-@end

+ 0 - 70
jiaPei/OLD/Util/Pay/Util/base64.h

@@ -1,70 +0,0 @@
-/**
- * \file base64.h
- */
-#ifndef XYSSL_BASE64_H
-#define XYSSL_BASE64_H
-
-#define XYSSL_ERR_BASE64_INVALID_CHARACTER              -0x0012
-#define XYSSL_ERR_BASE64_BUFFER_TOO_SMALL               -0x0010
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief          Encode a buffer into base64 format
- *
- * \param dst      destination buffer
- * \param dlen     size of the buffer
- * \param src      source buffer
- * \param slen     amount of data to be encoded
- *
- * \return         0 if successful, or XYSSL_ERR_BASE64_BUFFER_TOO_SMALL.
- *                 *dlen is always updated to reflect the amount
- *                 of data that has (or would have) been written.
- *
- * \note           Call this function with *dlen = 0 to obtain the
- *                 required buffer size in *dlen
- */
-int base64_encode( unsigned char *dst, int *dlen,
-                   unsigned char *src, int  slen );
-
-/**
- * \brief          Decode a base64-formatted buffer
- *
- * \param dst      destination buffer
- * \param dlen     size of the buffer
- * \param src      source buffer
- * \param slen     amount of data to be decoded
- *
- * \return         0 if successful, XYSSL_ERR_BASE64_BUFFER_TOO_SMALL, or
- *                 XYSSL_ERR_BASE64_INVALID_DATA if the input data is not
- *                 correct. *dlen is always updated to reflect the amount
- *                 of data that has (or would have) been written.
- *
- * \note           Call this function with *dlen = 0 to obtain the
- *                 required buffer size in *dlen
- */
-int base64_decode( unsigned char *dst, int *dlen,
-                   unsigned char *src, int  slen );
-
-/**
- * \brief          Checkup routine
- *
- * \return         0 if successful, or 1 if the test failed
- */
-int base64_self_test( int verbose );
-
-#ifdef __cplusplus
-}
-#endif
-
-
-@interface Base64 : NSObject
-
-+ (NSData *)decodeString:(NSString *)string;
-
-@end
-
-
-#endif /* base64.h */

+ 0 - 211
jiaPei/OLD/Util/Pay/Util/base64.m

@@ -1,211 +0,0 @@
-/*
- *  RFC 1521 base64 encoding/decoding
- *
- *  Copyright (C) 2006-2007  Christophe Devine
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-//#include "stdafx.h"
-#include "config.h"
-
-#if defined(XYSSL_BASE64_C)
-
-#include "base64.h"
-
-static const unsigned char base64_enc_map[64] =
-{
-    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
-    'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
-    'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
-    'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
-    'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
-    'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
-    '8', '9', '+', '/'
-};
-
-static const unsigned char base64_dec_map[128] =
-{
-    127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
-    127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
-    127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
-    127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
-    127, 127, 127,  62, 127, 127, 127,  63,  52,  53,
-     54,  55,  56,  57,  58,  59,  60,  61, 127, 127,
-    127,  64, 127, 127, 127,   0,   1,   2,   3,   4,
-      5,   6,   7,   8,   9,  10,  11,  12,  13,  14,
-     15,  16,  17,  18,  19,  20,  21,  22,  23,  24,
-     25, 127, 127, 127, 127, 127, 127,  26,  27,  28,
-     29,  30,  31,  32,  33,  34,  35,  36,  37,  38,
-     39,  40,  41,  42,  43,  44,  45,  46,  47,  48,
-     49,  50,  51, 127, 127, 127, 127, 127
-};
-
-/*
- * Encode a buffer into base64 format
- */
-int base64_encode( unsigned char *dst, int *dlen,
-                   unsigned char *src, int  slen )
-{
-    int i, n;
-    int C1, C2, C3;
-    unsigned char *p;
-
-    if( slen == 0 )
-        return( 0 );
-
-    n = (slen << 3) / 6;
-
-    switch( (slen << 3) - (n * 6) )
-    {
-        case  2: n += 3; break;
-        case  4: n += 2; break;
-        default: break;
-    }
-
-    if( *dlen < n + 1 )
-    {
-        *dlen = n + 1;
-        return( XYSSL_ERR_BASE64_BUFFER_TOO_SMALL );
-    }
-
-    n = (slen / 3) * 3;
-
-    for( i = 0, p = dst; i < n; i += 3 )
-    {
-        C1 = *src++;
-        C2 = *src++;
-        C3 = *src++;
-
-        *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
-        *p++ = base64_enc_map[(((C1 &  3) << 4) + (C2 >> 4)) & 0x3F];
-        *p++ = base64_enc_map[(((C2 & 15) << 2) + (C3 >> 6)) & 0x3F];
-        *p++ = base64_enc_map[C3 & 0x3F];
-    }
-
-    if( i < slen )
-    {
-        C1 = *src++;
-        C2 = ((i + 1) < slen) ? *src++ : 0;
-
-        *p++ = base64_enc_map[(C1 >> 2) & 0x3F];
-        *p++ = base64_enc_map[(((C1 & 3) << 4) + (C2 >> 4)) & 0x3F];
-
-        if( (i + 1) < slen )
-             *p++ = base64_enc_map[((C2 & 15) << 2) & 0x3F];
-        else *p++ = '=';
-
-        *p++ = '=';
-    }
-
-    *dlen = (int)(p - dst);
-    *p = 0;
-
-    return( 0 );
-}
-
-/*
- * Decode a base64-formatted buffer
- */
-int base64_decode( unsigned char *dst, int *dlen,
-                   unsigned char *src, int  slen )
-{
-    int i, j, n;
-    unsigned long x;
-    unsigned char *p;
-
-    for( i = j = n = 0; i < slen; i++ )
-    {
-        if( ( slen - i ) >= 2 &&
-            src[i] == '\r' && src[i + 1] == '\n' )
-            continue;
-
-        if( src[i] == '\n' )
-            continue;
-
-        if( src[i] == '=' && ++j > 2 )
-            return( XYSSL_ERR_BASE64_INVALID_CHARACTER );
-
-        if( src[i] > 127 || base64_dec_map[src[i]] == 127 )
-            return( XYSSL_ERR_BASE64_INVALID_CHARACTER );
-
-        if( base64_dec_map[src[i]] < 64 && j != 0 )
-            return( XYSSL_ERR_BASE64_INVALID_CHARACTER );
-
-        n++;
-    }
-
-    if( n == 0 )
-        return( 0 );
-
-    n = ((n * 6) + 7) >> 3;
-
-    if( *dlen < n )
-    {
-        *dlen = n;
-        return( XYSSL_ERR_BASE64_BUFFER_TOO_SMALL );
-    }
-
-   for( j = 3, n = x = 0, p = dst; i > 0; i--, src++ )
-   {
-        if( *src == '\r' || *src == '\n' )
-            continue;
-
-        j -= ( base64_dec_map[*src] == 64 );
-        x  = (x << 6) | ( base64_dec_map[*src] & 0x3F );
-
-        if( ++n == 4 )
-        {
-            n = 0;
-            if( j > 0 ) *p++ = (unsigned char)( x >> 16 );
-            if( j > 1 ) *p++ = (unsigned char)( x >>  8 );
-            if( j > 2 ) *p++ = (unsigned char)( x       );
-        }
-    }
-
-    *dlen = (int)(p - dst);
-
-    return( 0 );
-}
-
-@implementation Base64
-
-+ (NSData *)decodeString:(NSString *)string {
-	
-	char *dst = NULL;
-	int dlen = 0;
-	
-	char *src = (char *)[string UTF8String];
-	int slen = (int)strlen((char *)src);
-	
-	int ret = base64_decode((unsigned char *)dst, &dlen, (unsigned char *)src, slen);
-	if (ret == XYSSL_ERR_BASE64_BUFFER_TOO_SMALL) {
-		dst = (char *)malloc(dlen);
-//		ret = base64_decode((unsigned char *)dst, &dlen, (unsigned char *)src, slen);
-        base64_decode((unsigned char *)dst, &dlen, (unsigned char *)src, slen);
-	}
-	
-	NSData *data = [NSData dataWithBytes:dst length:dlen];
-	if (dst != NULL) {
-		free(dst);
-	}
-	return data;
-}
-
-@end
-
-#endif
-
-
-

+ 0 - 285
jiaPei/OLD/Util/Pay/Util/config.h

@@ -1,285 +0,0 @@
-/**
- * \file config.h
- *
- * This set of compile-time options may be used to enable
- * or disable features selectively, and reduce the global
- * memory footprint.
- */
-#ifndef XYSSL_CONFIG_H
-#define XYSSL_CONFIG_H
-
-#ifndef _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE 1
-#endif
-
-/*
- * Uncomment if native integers are 8-bit wide.
- *
-#define XYSSL_HAVE_INT8
- */
-
-/*
- * Uncomment if native integers are 16-bit wide.
- *
-#define XYSSL_HAVE_INT16
- */
-
-/*
- * Uncomment if the compiler supports long long.
- *
-#define XYSSL_HAVE_LONGLONG
- */
-
-/*
- * Uncomment to enable the use of assembly code.
- */
-//#define XYSSL_HAVE_ASM
-
-/*
- * Uncomment if the CPU supports SSE2 (IA-32 specific).
- *
-#define XYSSL_HAVE_SSE2
- */
-
-/*
- * Enable all SSL/TLS debugging messages.
-#define XYSSL_DEBUG_MSG
- */
-
-/*
- * Enable the checkup functions (*_self_test).
- */
-#define XYSSL_SELF_TEST
-
-
-/*
- * Enable the prime-number generation code.
- */
-#define XYSSL_GENPRIME
-
-/*
- * Uncomment this macro to store the AES tables in ROM.
- *
-#define XYSSL_AES_ROM_TABLES
- */
-
-/*
- * Module:  library/aes.c
- * Caller:  library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- *      SSL_RSA_AES_128_SHA
- *      SSL_RSA_AES_256_SHA
- *      SSL_EDH_RSA_AES_256_SHA
- */
-#define XYSSL_AES_C
-
-/*
- * Module:  library/arc4.c
- * Caller:  library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- *      SSL_RSA_RC4_128_MD5
- *      SSL_RSA_RC4_128_SHA
- */
-#define XYSSL_ARC4_C
-
-/*
- * Module:  library/base64.c
- * Caller:  library/x509parse.c
- *
- * This module is required for X.509 support.
- */
-#define XYSSL_BASE64_C
-
-/*
- * Module:  library/bignum.c
- * Caller:  library/dhm.c
- *          library/rsa.c
- *          library/ssl_tls.c
- *          library/x509parse.c
- *
- * This module is required for RSA and DHM support.
- */
-#define XYSSL_BIGNUM_C
-
-/*
- * Module:  library/certs.c
- * Caller:
- *
- * This module is used for testing (ssl_client/server).
- */
-#define XYSSL_CERTS_C
-
-/*
- * Module:  library/debug.c
- * Caller:  library/ssl_cli.c
- *          library/ssl_srv.c
- *          library/ssl_tls.c
- *
- * This module provides debugging functions.
-#define XYSSL_DEBUG_C
- */
-
-/*
- * Module:  library/des.c
- * Caller:  library/ssl_tls.c
- *
- * This module enables the following ciphersuites:
- *      SSL_RSA_DES_168_SHA
- *      SSL_EDH_RSA_DES_168_SHA
- */
-#define XYSSL_DES_C
-
-/*
- * Module:  library/dhm.c
- * Caller:  library/ssl_cli.c
- *          library/ssl_srv.c
- *
- * This module enables the following ciphersuites:
- *      SSL_EDH_RSA_DES_168_SHA
- *      SSL_EDH_RSA_AES_256_SHA
- */
-#define XYSSL_DHM_C
-
-/*
- * Module:  library/havege.c
- * Caller:
- *
- * This module enables the HAVEGE random number generator.
- */
-#define XYSSL_HAVEGE_C
-
-/*
- * Module:  library/md2.c
- * Caller:  library/x509parse.c
- *
- * Uncomment to enable support for (rare) MD2-signed X.509 certs.
- *
-#define XYSSL_MD2_C
- */
-
-/*
- * Module:  library/md4.c
- * Caller:  library/x509parse.c
- *
- * Uncomment to enable support for (rare) MD4-signed X.509 certs.
- *
-#define XYSSL_MD4_C
- */
-
-/*
- * Module:  library/md5.c
- * Caller:  library/ssl_tls.c
- *          library/x509parse.c
- *
- * This module is required for SSL/TLS and X.509.
- */
-#define XYSSL_MD5_C
-
-/*
- * Module:  library/net.c
- * Caller:
- *
- * This module provides TCP/IP networking routines.
- */
-#define XYSSL_NET_C
-
-/*
- * Module:  library/padlock.c
- * Caller:  library/aes.c
- *
- * This modules adds support for the VIA PadLock on x86.
- */
-#define XYSSL_PADLOCK_C
-
-/*
- * Module:  library/rsa.c
- * Caller:  library/ssl_cli.c
- *          library/ssl_srv.c
- *          library/ssl_tls.c
- *          library/x509.c
- *
- * This module is required for SSL/TLS and MD5-signed certificates.
- */
-#define XYSSL_RSA_C
-
-/*
- * Module:  library/sha1.c
- * Caller:  library/ssl_cli.c
- *          library/ssl_srv.c
- *          library/ssl_tls.c
- *          library/x509parse.c
- *
- * This module is required for SSL/TLS and SHA1-signed certificates.
- */
-#define XYSSL_SHA1_C
-
-/*
- * Module:  library/sha2.c
- * Caller:
- *
- * This module adds support for SHA-224 and SHA-256.
- */
-#define XYSSL_SHA2_C
-
-/*
- * Module:  library/sha4.c
- * Caller:
- *
- * This module adds support for SHA-384 and SHA-512.
- */
-#define XYSSL_SHA4_C
-
-/*
- * Module:  library/ssl_cli.c
- * Caller:
- *
- * This module is required for SSL/TLS client support.
- */
-#define XYSSL_SSL_CLI_C
-
-/*
- * Module:  library/ssl_srv.c
- * Caller:
- *
- * This module is required for SSL/TLS server support.
- */
-#define XYSSL_SSL_SRV_C
-
-/*
- * Module:  library/ssl_tls.c
- * Caller:  library/ssl_cli.c
- *          library/ssl_srv.c
- *
- * This module is required for SSL/TLS.
- */
-#define XYSSL_SSL_TLS_C
-
-/*
- * Module:  library/timing.c
- * Caller:  library/havege.c
- *
- * This module is used by the HAVEGE random number generator.
- */
-#define XYSSL_TIMING_C
-
-/*
- * Module:  library/x509parse.c
- * Caller:  library/ssl_cli.c
- *          library/ssl_srv.c
- *          library/ssl_tls.c
- *
- * This module is required for X.509 certificate parsing.
- */
-#define XYSSL_X509_PARSE_C
-
-/*
- * Module:  library/x509_write.c
- * Caller:
- *
- * This module is required for X.509 certificate writing.
- */
-#define XYSSL_X509_WRITE_C
-
-#endif /* config.h */

+ 0 - 20
jiaPei/OLD/Util/Pay/Util/openssl_wrapper.h

@@ -1,20 +0,0 @@
-//
-//  openssl_wrapper.h
-//  ThirdDemoApp
-//
-//  Created by Xu Hanjie on 11-1-20.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-int rsa_sign_with_private_key_pem(char *message, int message_length
-                                  , unsigned char *signature, unsigned int *signature_length
-                                  , char *private_key_file_path);
-int rsa_verify_with_public_key_pem(char *message, int message_length
-                                   , unsigned char *signature, unsigned int signature_length
-                                   , char *public_key_file_path);
-
-NSString *base64StringFromData(NSData *signature);
-NSData *dataFromBase64String(NSString *base64String);
-NSString *rsaSignString(NSString *stringToSign, NSString *privateKeyFilePath, BOOL *signSuccess);
-void rsaVerifyString(NSString *stringToVerify, NSString *signature, NSString *publicKeyFilePath, BOOL *verifySuccess);
-NSString *formattedPEMString(NSString *originalString);

+ 0 - 175
jiaPei/OLD/Util/Pay/Util/openssl_wrapper.m

@@ -1,175 +0,0 @@
-//
-//  openssl_wrapper.m
-//  ThirdDemoApp
-//
-//  Created by Xu Hanjie on 11-1-20.
-//  Copyright 2011 __MyCompanyName__. All rights reserved.
-//
-
-#import "openssl_wrapper.h"
-#import <openssl/rsa.h>
-#include <openssl/pem.h>
-#include <openssl/md5.h>
-#include <openssl/bio.h>
-#include <openssl/sha.h>
-#include <string.h>
-
-
-int rsa_sign_with_private_key_pem(char *message, int message_length
-                                  , unsigned char *signature, unsigned int *signature_length
-                                  , char *private_key_file_path)
-{
-    unsigned char sha1[20];
-    SHA1((unsigned char *)message, message_length, sha1);
-    int success = 0;
-    BIO *bio_private = NULL;
-    RSA *rsa_private = NULL;
-    bio_private = BIO_new(BIO_s_file());
-    BIO_read_filename(bio_private, private_key_file_path);
-    rsa_private = PEM_read_bio_RSAPrivateKey(bio_private, NULL, NULL, "");    
-	if (rsa_private != nil) {
-		if (1 == RSA_check_key(rsa_private))
-		{
-			int rsa_sign_valid = RSA_sign(NID_sha1
-										  , sha1, 20
-										  , signature, signature_length
-										  , rsa_private);
-			if (1 == rsa_sign_valid)
-			{
-				success = 1;
-			}
-		}
-		BIO_free_all(bio_private);
-	}
-	else {
-		NSLog(@"rsa_private read error : private key is NULL");
-	}
-
-    return success;
-}
-
-int rsa_verify_with_public_key_pem(char *message, int message_length
-                                   , unsigned char *signature, unsigned int signature_length
-                                   , char *public_key_file_path)
-{
-    unsigned char sha1[20];
-    SHA1((unsigned char *)message, message_length, sha1);
-    BIO *bio_public = NULL;
-    RSA *rsa_public = NULL;
-    bio_public = BIO_new(BIO_s_file());
-    BIO_read_filename(bio_public, public_key_file_path);
-    rsa_public = PEM_read_bio_RSA_PUBKEY(bio_public, NULL, NULL, NULL);
-    
-    int rsa_verify_valid = RSA_verify(NID_sha1
-                                      , sha1, 20
-                                      , signature, signature_length
-                                      , rsa_public);
-    BIO_free_all(bio_public);
-    if (1 == rsa_verify_valid)
-    {
-        return 1;
-    }
-    return 0;
-}
-
-NSString *base64StringFromData(NSData *signature)
-{
-    int signatureLength = (int)[signature length];
-    unsigned char *outputBuffer = (unsigned char *)malloc(2 * 4 * (signatureLength / 3 + 1));
-    int outputLength = EVP_EncodeBlock(outputBuffer, [signature bytes], signatureLength);
-    outputBuffer[outputLength] = '\0';
-    NSString *base64String = [NSString stringWithCString:(char *)outputBuffer encoding:NSASCIIStringEncoding];
-    free(outputBuffer);
-    return base64String;
-}
-
-NSData *dataFromBase64String(NSString *base64String)
-{
-    int stringLength = (int)[base64String length];
-    const unsigned char *strBuffer = (const unsigned char *)[base64String UTF8String];
-    unsigned char *outputBuffer = (unsigned char *)malloc(2 * 3 * (stringLength / 4 + 1));
-    int outputLength = EVP_DecodeBlock(outputBuffer, strBuffer, stringLength);
-    
-    int zeroByteCounter = 0;
-    for (int i = stringLength - 1; i >= 0; i--)
-    {
-        if (strBuffer[i] == '=')
-        {
-            zeroByteCounter++;
-        }
-        else
-        {
-            break;
-        }
-    }
-    
-    NSData *data = [[NSData alloc] initWithBytes:outputBuffer length:outputLength - zeroByteCounter];
-    free(outputBuffer);
-    return data;
-}
-
-NSString *rsaSignString(NSString *stringToSign, NSString *privateKeyFilePath, BOOL *signSuccess)
-{
-    const char *message = [stringToSign cStringUsingEncoding:NSUTF8StringEncoding];
-    int messageLength = (int)strlen(message);
-    unsigned char *sig = (unsigned char *)malloc(256);
-    unsigned int sig_len;
-    char *filePath = (char *)[privateKeyFilePath cStringUsingEncoding:NSUTF8StringEncoding];
-    int sign_ok = rsa_sign_with_private_key_pem((char *)message, messageLength
-                                                , sig, &sig_len
-                                                , filePath);
-    NSString *signedString = nil;
-    if (1 == sign_ok)
-    {
-        *signSuccess = YES;
-        signedString = base64StringFromData([NSData dataWithBytes:sig length:sig_len]);
-    }
-    else
-    {
-        *signSuccess = NO;
-    }
-    free(sig);
-    return signedString;
-}
-
-void rsaVerifyString(NSString *stringToVerify, NSString *signature, NSString *publicKeyFilePath, BOOL *verifySuccess)
-{
-    const char *message = [stringToVerify cStringUsingEncoding:NSUTF8StringEncoding];
-    int messageLength = (int)[stringToVerify lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
-    NSData *signatureData = dataFromBase64String(signature);
-    unsigned char *sig = (unsigned char *)[signatureData bytes];
-    unsigned int sig_len = (int)[signatureData length];
-    char *filePath = (char *)[publicKeyFilePath cStringUsingEncoding:NSUTF8StringEncoding];
-    int verify_ok = rsa_verify_with_public_key_pem((char *)message, messageLength
-                                                   , sig, sig_len
-                                                   , filePath);
-    if (1 == verify_ok)
-    {
-        *verifySuccess = YES;
-    }
-    else
-    {
-        *verifySuccess = NO;
-    }
-}
-
-NSString *formattedPEMString(NSString *originalString)
-{    
-    NSString *trimmedString = [originalString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
-    const char *c = [trimmedString UTF8String];
-    int len = (int)[trimmedString length];
-    NSMutableString *result = [NSMutableString string];
-    [result appendString:@"-----BEGIN PRIVATE KEY-----\n"];
-    int index = 0;
-    while (index < len) {
-        char cc = c[index];
-        [result appendFormat:@"%c", cc];
-        if ( (index+1) % 64 == 0)
-        {
-            [result appendString:@"\n"];
-        }
-        index++;
-    }
-    [result appendString:@"\n-----END PRIVATE KEY-----"];
-    return result;
-}

+ 0 - 31
jiaPei/OLD/Util/WXPay/ApiXml.h

@@ -1,31 +0,0 @@
-
-
-#import <Foundation/Foundation.h>
-/*
- XML 解析库api说明:
- //============================================================================
- 
- //输入参数为xml格式串,初始化解析器
- -(void)startParse:(NSData *)data;
- 
- //获取解析后的字典
--(NSMutableDictionary*) getDict;
- 
-//============================================================================
- */
-@interface XMLHelper : NSObject<NSXMLParserDelegate> {
-
-    //解析器
-    NSXMLParser *xmlParser;
-    //解析元素
-    NSMutableArray *xmlElements;
-    //解析结果
-    NSMutableDictionary *dictionary;
-    //临时串变量
-    NSMutableString *contentString;
-}
- //输入参数为xml格式串,初始化解析器
--(void)startParse:(NSData *)data;
- //获取解析后的字典
--(NSMutableDictionary*) getDict;
-@end

+ 0 - 53
jiaPei/OLD/Util/WXPay/ApiXml.mm

@@ -1,53 +0,0 @@
-
-#import <Foundation/Foundation.h>
-#import "ApiXml.h"
-/*
- XML 解析库
- */
-@implementation XMLHelper
--(void) startParse:(NSData *)data{
-
-    dictionary =[NSMutableDictionary dictionary];
-    contentString=[NSMutableString string];
-    
-    //Demo XML解析实例
-    xmlElements = [[NSMutableArray alloc] init];
-    
-    xmlParser = [[NSXMLParser alloc] initWithData:data];
-
-    [xmlParser setDelegate:self];
-    [xmlParser parse];
-    
-}
--(NSMutableDictionary*) getDict{
-    return dictionary;
-}
-//解析文档开始
-- (void)parserDidStartDocument:(NSXMLParser *)parser{
-    //NSLog(@"解析文档开始");
-}
-- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
-    //NSLog(@"遇到启始标签:%@",elementName);
-}
-
-- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
-    //NSLog(@"遇到内容:%@",string);
-    [contentString setString:string];
-}
-
-- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
-    //NSLog(@"遇到结束标签:%@",elementName);
-    
-    if( ![contentString isEqualToString:@"\n"] && ![elementName isEqualToString:@"root"]){
-        [dictionary setObject: [contentString copy] forKey:elementName];
-        //NSLog(@"%@=%@",elementName, contentString);
-    }
-}
-
-//解析文档结束
-- (void)parserDidEndDocument:(NSXMLParser *)parser{
-    //NSLog(@"文档解析结束");
-
-}
-
-@end

+ 0 - 18
jiaPei/OLD/Util/WXPay/WXUtil.h

@@ -1,18 +0,0 @@
-
-
-#import <Foundation/Foundation.h>
-#import <CommonCrypto/CommonDigest.h>
-
-@interface WXUtil :NSObject <NSXMLParserDelegate>
-{
-}
-/*
- 加密实现MD5和SHA1
- */
-+(NSString *) md5:(NSString *)str;
-+(NSString*) sha1:(NSString *)str;
-/**
- 实现http GET/POST 解析返回的json数据
- */
-+(NSData *) httpSend:(NSString *)url method:(NSString *)method data:(NSString *)data;
-@end

+ 0 - 66
jiaPei/OLD/Util/WXPay/WXUtil.mm

@@ -1,66 +0,0 @@
-
-#import <Foundation/Foundation.h>
-#import "WXUtil.h"
-/*
- 加密实现MD5和SHA1
- */
-@implementation WXUtil
-
-//md5 encode
-+(NSString *) md5:(NSString *)str
-{
-    const char *cStr = [str UTF8String];
-    unsigned char digest[CC_MD5_DIGEST_LENGTH];
-    CC_MD5( cStr, (unsigned int)strlen(cStr), digest );
-    
-    NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
-    
-    for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
-        [output appendFormat:@"%02X", digest[i]];
-    
-    return output;
-}
-//sha1 encode
-+(NSString*) sha1:(NSString *)str
-{
-    const char *cstr = [str cStringUsingEncoding:NSUTF8StringEncoding];
-    NSData *data = [NSData dataWithBytes:cstr length:str.length];
-    
-    uint8_t digest[CC_SHA1_DIGEST_LENGTH];
-    
-    CC_SHA1(data.bytes, (unsigned int)data.length, digest);
-    
-    NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
-    
-    for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
-        [output appendFormat:@"%02x", digest[i]];
-    
-    return output;
-}
-//http 请求
-+(NSData *) httpSend:(NSString *)url method:(NSString *)method data:(NSString *)data
-{
-	dispatch_group_t group = dispatch_group_create();
-	dispatch_group_enter(group);
-    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:5];
-    //设置提交方式
-    [request setHTTPMethod:method];
-    //设置数据类型
-    [request addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
-    //设置编码
-    [request setValue:@"UTF-8" forHTTPHeaderField:@"charset"];
-    //如果是POST
-    [request setHTTPBody:[data dataUsingEncoding:NSUTF8StringEncoding]];
-    
-    //将请求的url数据放到NSData对象中
-	__block NSData *resultData = [NSData data];
-	NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
-		resultData = data;
-		dispatch_group_leave(group);
-	}];
-	[task resume];
-	dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
-	return resultData;
-}
-
-@end

+ 0 - 86
jiaPei/OLD/Util/WXPay/payRequsestHandler.h

@@ -1,86 +0,0 @@
-
-
-#import <Foundation/Foundation.h>
-#import "WXUtil.h"
-#import "ApiXml.h"
-/*
- // 签名实例
- // 更新时间:2015年3月3日
- // 负责人:李启波(marcyli)
- // 该Demo用于ios sdk 1.4
- 
- //微信支付服务器签名支付请求请求类
- //============================================================================
- //api说明:
- //初始化商户参数,默认给一些参数赋值,如cmdno,date等。
- -(BOOL) init:(NSString *)app_id (NSString *)mch_id;
- 
- //设置商户API密钥
- -(void) setKey:(NSString *)key;
- 
- //生成签名
- -(NSString*) createMd5Sign:(NSMutableDictionary*)dict;
- 
- //获取XML格式的数据
- -(NSString *) genPackage:(NSMutableDictionary*)packageParams;
- 
- //提交预支付交易,获取预支付交易会话标识
- -(NSString *) sendPrepay:(NSMutableDictionary *);
- 
- //签名实例测试
- - ( NSMutableDictionary *)sendPay_demo;
- 
- //获取debug信息日志
- -(NSString *) getDebugifo;
- 
- //获取最后返回的错误代码
- -(long) getLasterrCode;
- //============================================================================
- */
-
-//通知的名字及参数
-#define WX_PAY_RESULT   @"weixin_pay_result_isSuccessed"
-#define IS_SUCCESSED    @"wechat_pay_isSuccessed"
-#define IS_FAILED       @"wechat_pay_isFailed"
-
-
-#define APP_ID          @"wx0612ab5e43332b11"         //微信APPID
-#define APP_SECRET      @"这里填写你获取的微信AppSecret" //微信appsecret
-//商户号,填写商户对应参数(客户给)
-#define MCH_ID          @"1374381302"
-//商户API密钥,填写相应参数(客户给)
-#define PARTNER_ID      @"这里填写商户API密钥,客户会给你"
-//支付结果回调页面(后台会给你)
-#define NOTIFY_URL      @"这里填写后台给你的微信支付的后台接口网址"
-
-#define QDApp_Id     1305573081
-#define QDSecret_ID     @"AKIDJoy2xuMlHAB0nXAf3Phy34yuiSIdr8LU"     //语音
-#define QDSecret_Key    @"97tU0Tnz3xiKk9qT6pL0jijZL3kGbkhV"         //语音key
-
-
-@interface payRequsestHandler : NSObject{
-	//预支付网关url地址
-    NSString *payUrl;
-
-    //lash_errcode;
-    long     last_errcode;
-	//debug信息
-    NSMutableString *debugInfo;
-    NSString *appid,*mchid,*spkey;
-}
-//初始化函数
--(BOOL) init:(NSString *)app_id mch_id:(NSString *)mch_id;
--(NSString *) getDebugifo;
--(long) getLasterrCode;
-//设置商户密钥
--(void) setKey:(NSString *)key;
-//创建package签名
--(NSString*) createMd5Sign:(NSMutableDictionary*)dict;
-//获取package带参数的签名包
--(NSString *)genPackage:(NSMutableDictionary*)packageParams;
-//提交预支付
--(NSString *)sendPrepay:(NSMutableDictionary *)prePayParams;
-//签名实例测试
-- ( NSMutableDictionary *)sendPay_demo;
-
-@end

+ 0 - 217
jiaPei/OLD/Util/WXPay/payRequsestHandler.mm

@@ -1,217 +0,0 @@
-
-#import <Foundation/Foundation.h>
-#import "payRequsestHandler.h"
-/*
- 服务器请求操作处理
- */
-@implementation payRequsestHandler
-
-//初始化函数
--(BOOL) init:(NSString *)app_id mch_id:(NSString *)mch_id;
-{
-    //初始构造函数
-    payUrl     = @"https://api.mch.weixin.qq.com/pay/unifiedorder";
-    if (debugInfo == nil){
-        debugInfo   = [NSMutableString string];
-    }
-    [debugInfo setString:@""];
-    appid   = app_id;
-    mchid   = mch_id;
-    return YES;
-}
-//设置商户密钥
--(void) setKey:(NSString *)key
-{
-    spkey  = [NSString stringWithString:key];
-}
-//获取debug信息
--(NSString*) getDebugifo
-{
-    NSString    *res = [NSString stringWithString:debugInfo];
-    [debugInfo setString:@""];
-    return res;
-}
-//获取最后服务返回错误代码
--(long) getLasterrCode
-{
-    return last_errcode;
-}
-//创建package签名
--(NSString*) createMd5Sign:(NSMutableDictionary*)dict
-{
-    NSMutableString *contentString  =[NSMutableString string];
-    NSArray *keys = [dict allKeys];
-    //按字母顺序排序
-    NSArray *sortedArray = [keys sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
-        return [obj1 compare:obj2 options:NSNumericSearch];
-    }];
-    //拼接字符串
-    for (NSString *categoryId in sortedArray) {
-        if (   ![[dict objectForKey:categoryId] isEqualToString:@""]
-            && ![categoryId isEqualToString:@"sign"]
-            && ![categoryId isEqualToString:@"key"]
-            )
-        {
-            [contentString appendFormat:@"%@=%@&", categoryId, [dict objectForKey:categoryId]];
-        }
-        
-    }
-    //添加key字段
-    [contentString appendFormat:@"key=%@", spkey];
-    //得到MD5 sign签名
-    NSString *md5Sign =[WXUtil md5:contentString];
-    
-    //输出Debug Info
-    [debugInfo appendFormat:@"MD5签名字符串:\n%@\n\n",contentString];
-
-    return md5Sign;
-}
-
-//获取package带参数的签名包
--(NSString *)genPackage:(NSMutableDictionary*)packageParams
-{
-    NSString *sign;
-    NSMutableString *reqPars=[NSMutableString string];
-    //生成签名
-    sign        = [self createMd5Sign:packageParams];
-    //生成xml的package
-    NSArray *keys = [packageParams allKeys];
-    [reqPars appendString:@"<xml>\n"];
-    for (NSString *categoryId in keys) {
-        [reqPars appendFormat:@"<%@>%@</%@>\n", categoryId, [packageParams objectForKey:categoryId],categoryId];
-    }
-    [reqPars appendFormat:@"<sign>%@</sign>\n</xml>", sign];
-    
-    return [NSString stringWithString:reqPars];
-}
-//提交预支付
--(NSString *)sendPrepay:(NSMutableDictionary *)prePayParams
-{
-    NSString *prepayid = nil;
-    
-    //获取提交支付
-    NSString *send      = [self genPackage:prePayParams];
-    
-    //输出Debug Info
-    [debugInfo appendFormat:@"API链接:%@\n", payUrl];
-    [debugInfo appendFormat:@"发送的xml:%@\n", send];
-    
-    //发送请求post xml数据
-    NSData *res = [WXUtil httpSend:payUrl method:@"POST" data:send];
-    
-    //输出Debug Info
-    [debugInfo appendFormat:@"服务器返回:\n%@\n\n",[[NSString alloc] initWithData:res encoding:NSUTF8StringEncoding]];
-    
-    XMLHelper *xml  = [[XMLHelper alloc] init];
-    
-    //开始解析
-    [xml startParse:res];
-    
-    NSMutableDictionary *resParams = [xml getDict];
-
-    //判断返回
-    NSString *return_code   = [resParams objectForKey:@"return_code"];
-    NSString *result_code   = [resParams objectForKey:@"result_code"];
-    if ( [return_code isEqualToString:@"SUCCESS"] )
-    {
-        //生成返回数据的签名
-        NSString *sign      = [self createMd5Sign:resParams ];
-        NSString *send_sign =[resParams objectForKey:@"sign"] ;
-        
-        //验证签名正确性
-        if( [sign isEqualToString:send_sign]){
-            if( [result_code isEqualToString:@"SUCCESS"]) {
-                //验证业务处理状态
-                prepayid    = [resParams objectForKey:@"prepay_id"];
-                return_code = 0;
-                
-                [debugInfo appendFormat:@"获取预支付交易标示成功!\n"];
-            }
-        }else{
-            last_errcode = 1;
-            [debugInfo appendFormat:@"gen_sign=%@\n   _sign=%@\n",sign,send_sign];
-            [debugInfo appendFormat:@"服务器返回签名验证错误!!!\n"];
-        }
-    }else{
-        last_errcode = 2;
-        [debugInfo appendFormat:@"接口返回错误!!!\n"];
-    }
-
-    return prepayid;
-}
-//============================================================
-// V3V4支付流程模拟实现,只作帐号验证和演示
-// 注意:此demo只适合开发调试,参数配置和参数加密需要放到服务器端处理
-// 服务器端Demo请查看包的文件
-// 更新时间:2015年3月3日
-// 负责人:李启波(marcyli)
-//============================================================
-- ( NSMutableDictionary *)sendPay_demo
-{
-    //订单标题,展示给用户
-    NSString *order_name    = @"V3支付测试";
-    //订单金额,单位(分)
-    NSString *order_price   = @"1";//1分钱测试
-
-
-    //================================
-    //预付单参数订单设置
-    //================================
-    srand( (unsigned)time(0) );
-    NSString *noncestr  = [NSString stringWithFormat:@"%d", rand()];
-    NSString *orderno   = [NSString stringWithFormat:@"%ld",time(0)];
-    NSMutableDictionary *packageParams = [NSMutableDictionary dictionary];
-    
-    [packageParams setObject: appid             forKey:@"appid"];       //开放平台appid
-    [packageParams setObject: mchid             forKey:@"mch_id"];      //商户号
-    [packageParams setObject: @"APP-001"        forKey:@"device_info"]; //支付设备号或门店号
-    [packageParams setObject: noncestr          forKey:@"nonce_str"];   //随机串
-    [packageParams setObject: @"APP"            forKey:@"trade_type"];  //支付类型,固定为APP
-    [packageParams setObject: order_name        forKey:@"body"];        //订单描述,展示给用户
-    [packageParams setObject: NOTIFY_URL        forKey:@"notify_url"];  //支付结果异步通知
-    [packageParams setObject: orderno           forKey:@"out_trade_no"];//商户订单号
-    [packageParams setObject: @"196.168.1.1"    forKey:@"spbill_create_ip"];//发器支付的机器ip
-    [packageParams setObject: order_price       forKey:@"total_fee"];       //订单金额,单位为分
-    
-    //获取prepayId(预支付交易会话标识)
-    NSString *prePayid;
-    prePayid            = [self sendPrepay:packageParams];
-    
-    if ( prePayid != nil) {
-        //获取到prepayid后进行第二次签名
-        
-        NSString    *package, *time_stamp, *nonce_str;
-        //设置支付参数
-        time_t now;
-        time(&now);
-        time_stamp  = [NSString stringWithFormat:@"%ld", now];
-        nonce_str	= [WXUtil md5:time_stamp];
-        //重新按提交格式组包,微信客户端暂只支持package=Sign=WXPay格式,须考虑升级后支持携带package具体参数的情况
-        //package       = [NSString stringWithFormat:@"Sign=%@",package];
-        package         = @"Sign=WXPay";
-        //第二次签名参数列表
-        NSMutableDictionary *signParams = [NSMutableDictionary dictionary];
-        [signParams setObject: appid        forKey:@"appid"];
-        [signParams setObject: nonce_str    forKey:@"noncestr"];
-        [signParams setObject: package      forKey:@"package"];
-        [signParams setObject: mchid        forKey:@"partnerid"];
-        [signParams setObject: time_stamp   forKey:@"timestamp"];
-        [signParams setObject: prePayid     forKey:@"prepayid"];
-        //[signParams setObject: @"MD5"       forKey:@"signType"];
-        //生成签名
-        NSString *sign  = [self createMd5Sign:signParams];
-        
-        //添加签名
-        [signParams setObject: sign         forKey:@"sign"];
-        
-        [debugInfo appendFormat:@"第二步签名成功,sign=%@\n",sign];
-        
-        //返回参数列表
-        return signParams;
-        
-    }else{
-        [debugInfo appendFormat:@"获取prepayid失败!\n"];
-    }
-    return nil;
-}
-@end