如何在 iPhone 中加密信用卡号码

发布于 2024-11-04 01:17:55 字数 1385 浏览 0 评论 0原文

我想通过邮寄方式发送信用卡号码,但信用卡号码应该采用加密形式。如何加密呢?

我的代码是:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姐不稀罕 2024-11-11 01:17:55
  1. 确保在准备启动应用程序时使用安全服务器 (https://)
  2. 查看一些 AES 加密示例和 Apple 的 CryptoExercise。

Apple 的 CryptoExercise< /a>

iPhone 上 NSString 的 AES 加密

  1. Make sure you use a secure server when you prepare to launch your application (https://)
  2. Look at some AES encryption examples and Apples CryptoExercise.

Apple's CryptoExercise

AES Encryption for an NSString on the iPhone

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文