我按照以下步骤集成了无耻的CCAvenue
GateWay
步骤:-
我有我的商家 ID 和访问代码(url、ip)。
- 我正在调用我的服务器来获取 RSA key 参数(access_code、order_id)
//我的服务器已经在 CCAvenue 服务器中注册 2.我的服务器调用Avenue获取RSA key
3.my服务器转发RSA key
4.一旦我得到了,我将删除多余的行“\n”,双引号“”--“”,和“\”
// removing double quates
NSString * newReplacedString2 = [rsaKey stringByReplacingOccurrencesOfString:@"\"" withString:@""];
//removing /n in the key
NSString * newReplacedString = [newReplacedString2 stringByReplacingOccurrencesOfString:@"\\n" withString:@""];
//removing / in the key
NSString * newReplacedString1 = [newReplacedString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
5.我将该键放在
之间rsaKey = [NSString stringWithFormat:@"-----BEGIN PUBLIC KEY-----\n%@\n-----END PUBLIC KEY-----\n",newReplacedString1];
//*******//***//****//**// output //*******//***//****//**//
-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuV7OdmPSutrlOE9lF3YdW4ymGn+qselCOycMk95Tobw1PcqCeAWkrnxUECpAdnHGrUKmFbEDHs3wnwzLTbfa3GvE5dvvmluug78X3RYEFQiMh1QpfS5fBfvs4WQKw7oigko3G0UwZLZFnZ4E4WKTQi4wbCgjwQJFMnMGJfFYNcoSJluVg/q8z3bVxfDOV0ZPWccmvA3bTf9YFHKCC3clscQrGf1NPnBGcBGm+s06t3EljoSmpjtyTgSiGrqBZ8TSCQxoyXxS+RkhNTigg6mqW9hIisxYYqlbzvRnCDhuqgZfmP7t65QG5raELVE7d+Ia+dgh024luZ9+vSk4Qb65DQIDAQAB -----END PUBLIC KEY-----
我正在使用CCTool加密金额和价格
NSString *myRequestString = [NSString stringWithFormat:@"amount=%@¤cy=%@",amount,currency];(2,INR) CCTool *ccTool = [[CCTool alloc] init]; NSString *encVal = [ccTool encryptRSA:myRequestString key:rsaKey];
因为我正在获取Exe_Bad_Acess
RSA *rsa = PEM_read_bio_RSA_PUBKEY(bufio, NULL,NULL,NULL);
RSA 出现错误。
如何解决这个问题。请帮助我。!!
最佳答案
嗨,谢谢大家的支持,我终于解决了我的问题。
一旦您从服务器获得 rsa key ,您需要删除新行“\n”、斜杠“\”和双引号“\””
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuV7OdmPSutrlOE9lF3YdW4ymGn+qselCOycMk95Tobw1PcqCeAWkrnxUECpAdnHGrUKmFbEDHs3wnwzLTbfa3GvE5dvvmluug78X3RYEFQiMh1QpfS5fBfvs4WQKw7oigko3G0UwZLZFnZ4E4WKTQi4wbCgjwQJFMnMGJfFYNcoSJluVg/q8z3bVxfDOV0ZPWccmvA3bTf9YFHKCC3clscQrGf1NPnBGcBGm+s06t3EljoSmpjtyTgSiGrqBZ8TSCQxoyXxS+RkhNTigg6mqW9hIisxYYqlbzvRnCDhuqgZfmP7t65QG5raELVE7d+Ia+dgh024luZ9+vSk4Qb65DQIDAQAB
这里我们需要将其转换为ba64加密格式的输入。
https://gist.github.com/superwills/5415344#file-openssl-rsa-encryption-sample-L154
你需要将我们的字符串转换得完全相同, 1. 每行“字符串”必须为64个字符宽。 2.必须以换行符结束
我正在更新我的代码。对我来说,它工作正常。
NSString *rsaKey = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
//NSString *rsaKey = [[NSString alloc] initWithData:数据编码:NSASCIIStringEncoding];
NSLog(@"%@",rsaKey);
//rsaKey = [rsaKey stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
//NSLog(@"%@",rsaKey);
// removing double quates
NSString * newReplacedString2 = [rsaKey stringByReplacingOccurrencesOfString:@"\"" withString:@""];
NSLog(@"%@",rsaKey);
//removing \n in the key
NSString * newReplacedString = [newReplacedString2 stringByReplacingOccurrencesOfString:@"\\n" withString:@""];
NSLog(@"%@",rsaKey);
//removing \ in the key
NSString * newReplacedString1 = [newReplacedString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
NSLog(@"%@",newReplacedString1);
NSString * abc = [NSString stringWithFormat:@"%@", newReplacedString1];
NSMutableString *sss=[NSMutableString new];
int j=(int)([abc length]/63);
for (int i=0; i<=j; i++) {
int k= i*63;
NSString * newString;
if (i != j) {
newString = [abc substringWithRange:NSMakeRange(k,63)];
NSLog(@"%lu",(unsigned long)newString.length);
newString=[NSString stringWithFormat:@"%@",newString];
}else{
newString = [abc substringWithRange:NSMakeRange(k,[abc length]-k)];
NSLog(@"%lu",(unsigned long)newString.length);
if (newString.length !=0)
newString=[NSString stringWithFormat:@"%@",newString];
}
if (newString.length !=0)
[sss appendString:[NSString stringWithFormat:@"%@\n",newString]];
}
NSLog(@"%@",sss);
rsaKey = [NSString stringWithFormat:@"-----BEGIN PUBLIC KEY-----\n%@-----END PUBLIC KEY-----\n",sss];
NSLog(@"%@",rsaKey);
//Encrypting Card Details
NSString *myRequestString = [NSString stringWithFormat:@"amount=%@¤cy=%@",amount,currency];
CCTool *ccTool = [[CCTool alloc] init];
NSLog(@"emcrpted data skfjsf jakdfhjklfhjk%@",[ccTool encryptRSA:myRequestString key:rsaKey]);
Happy Coding. :)
关于ios - 当我在 IOS 中集成 CCAvenue Payment Gate way 时,我收到 Exe_Bad_Access(code=1 address=0X38),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40215177/