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

时间:2011-04-28 12:50:39

标签: iphone objective-c encryption

我想通过邮寄方式发送信用卡号,但信用卡号应该是加密形式。如何加密它。请帮帮我。

我的代码是:

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!");

在上面我想以加密形式发送信用卡号。

提前致谢:

1 个答案:

答案 0 :(得分:0)

  1. 确保在准备启动应用程序时使用安全服务器(https://)
  2. 查看一些AES加密示例和Apples CryptoExcercise。
  3. Apple's CrptyoExcercise

    AES Encryption for an NSString on the iPhone