如何在 iPhone 中加密信用卡号码
我想通过邮寄方式发送信用卡号码,但信用卡号码应该采用加密形式。如何加密呢?
我的代码是:
NSString *fName = firstName.text;
NSString *lName = lastName.text;
NSString *phone = phoneNumber.text;
NSString *emailid = email.text;
NSString *cardNumber = creditCardNumber.text;
NSString *ID = particularEventPaidId;
NSString *postData = [NSString stringWithFormat:@"id=%@&firstname=%@&lastname=%@&phone=%@&email=%@&creditcard=%@",ID,fName,lName,phone,emailid,cardNumber];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSLog(@"postLength is: %@",postLength);
NSURL *url = [NSURL URLWithString:@"http://cfcdi.org/eassociation/web-service/event-register.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSData *requestBody = [postData dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:requestBody];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
NSURLResponse *response;
NSError *requestError;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError];
if(requestError==nil)
NSLog(@"Error is nil");
else
NSLog(@"Error is not nil");
NSLog(@"success!");
在上面我想以加密形式发送信用卡号。
I want to send credit card number through post method but the credit card number should be in encrypted form. How to encrypt it?
My code is:
NSString *fName = firstName.text;
NSString *lName = lastName.text;
NSString *phone = phoneNumber.text;
NSString *emailid = email.text;
NSString *cardNumber = creditCardNumber.text;
NSString *ID = particularEventPaidId;
NSString *postData = [NSString stringWithFormat:@"id=%@&firstname=%@&lastname=%@&phone=%@&email=%@&creditcard=%@",ID,fName,lName,phone,emailid,cardNumber];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSLog(@"postLength is: %@",postLength);
NSURL *url = [NSURL URLWithString:@"http://cfcdi.org/eassociation/web-service/event-register.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
NSData *requestBody = [postData dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:requestBody];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
NSURLResponse *response;
NSError *requestError;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError];
if(requestError==nil)
NSLog(@"Error is nil");
else
NSLog(@"Error is not nil");
NSLog(@"success!");
In above I want to send credit card number in encrypted form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Apple 的 CryptoExercise< /a>
iPhone 上 NSString 的 AES 加密
Apple's CryptoExercise
AES Encryption for an NSString on the iPhone