在iOS中加密NSString(不是NSData) - >发送到PHP服务器 - >让PHP服务器解密吗?

I know there is openSSL but I just want to use encryption.

Here is exactly what I wish to do.

1) encrypt NSString in xcode(objective-c) with AES-128 or whatever encryption method that works

2) send the encrypted NSString to PHP server using POST method. The parameter that will be sent to PHP server would look something like:

 @"fromClient1=string1&fromClient2=string2"

3) PHP server receives that data with something like this:

 $receivedStr1 = $_POST['fromClient1']; // string1
 $receivedStr2 = $_POST['fromClient2']; // string2

4) let PHP server decode $receivedStr1 and $receivedStr2 into plain texts

I have looked at https://github.com/RNCryptor/RNCryptor, but it's all about NSData encryption.

How do you receive encrypted NSData in PHP?? I only know how to use

$fromClient = $_POST['someData'];

but it won't work if the whole parameter is encrypted...

Can anyone help me out?? The purpose of this is to send the user's password( = NSString) to PHP server securely.

Following on from @Rory McKinnel, this code converts data into a base64 string which can be converted back into plain text or data (look here for more info).

To convert data in Objective-C:

NSString *base64String = [myData base64EncodedStringWithOptions:0];

Or in Swift:

let base64String = myData.base64EncodedStringWithOptions(options: 0)

EDIT:

NSString has two useful methods : 1) - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding and - (NSString *)stringByAddingPercentEncodingWithAllowedCharacters:(NSCharacterSet *)allowedCharacters.

These methods help convert an NSString into a legal URL string according to the docs these methods return:

A new string made by replacing in the receiver all percent escapes with the matching characters as determined by the given encoding encoding. Returns nil if the transformation is not possible, for example, the percent escapes give a byte sequence not legal in encoding.