Based on this link: https://github.com/RNCryptor/RNCryptor
I've learned that this is a basic method to encrypt NSData
NSData *data = [@"Data" dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSData *encryptedData = [RNEncryptor encryptData:data
withSettings:kRNCryptorAES256Settings
password:aPassword
error:&error];
And here is my code doing POST request to PHP-based server.
NSString *parameter = [NSString stringWithFormat:@"userid=%@&password=%@",useridStr, passwordStr];
NSData *parameterData = [parameter dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString: @"http://mywebiste.com/server.php"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPBody:parameterData];
[request setHTTPMethod:@"POST"];
[request addValue: @"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self];
And in PHP server :
<?php
$userid = $_POST['userid'];
$password = $_POST['password'];
...
?>
My question is
How would i received data in PHP server if the whole parameter
NSString *parameter = [NSString stringWithFormat:
@"userid=%@&password=%@",useridStr, passwordStr];
is encrypted??
Is there a way to encrypt ONLY NSString, and attached them to the parameter like this?
NSString *parameter = [NSString stringWithFormat:
@"userid=%@&password=%@",ENCRYPTED_USRID, ENCRYPTED_PWD];