+ (NSData *)encrypt:(NSString *)string
{
NSData *encryptedString;
NSError *error;
encryptedString = [RNEncryptor encryptData:[string dataUsingEncoding:NSUTF8StringEncoding]
withSettings:kRNCryptorAES256Settings
password:[MAEncryptDecrypt encryptDecryptKey]
error:&error];
return encryptedString;
}
NSData *encryptedString = [MAEncryptDecryptencrypt:@"hi, this will be encrypted..."]; // encrypts it using the above method
NSString *base64encoded = [encrypted base64EncodedStringWithOptions:0]; // encodes it with base64, so it can be send
NSMutableURLRequest *url = [[NSMutableURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:API_URL] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
[url setHTTPMethod:@"POST"];
// here the encrypted-string is added to the HTTP-body. q=encoded
NSString *HTTPBody = [NSString stringWithFormat@"q=%@", encoded];
[url setHTTPBody:[HTTPBody dataUsingEncoding:NSUTF8StringEncoding]];
[NSURLConnection connectionWithRequest:url delegate:self]; // send it to the server
<0301fecc d6fb4823 89a063b6 03269e91 872d82d0 fb01c421 7ea5aa5a def9af07 b32f9d06 34e93d63 5a408cf7 34f603f0 ebfc645d e02a2447 c4c71d14 a74eaa9f 67a9492b 12015b33 f18dcf56 6ca9e21d 62f30310 2e387673 79af66fd 4e2daa82 cda7>
AwH+zNb7SCOJoGO2AyaekYctgtD7AcQhfqWqWt75rwezL50GNOk9Y1pAjPc09gPw6/xkXeAqJEfExx0Up06qn2epSSsSAVsz8Y3PVmyp4h1i8wMQLjh2c3mvZv1OLaqCzac=
On the PHP-side the q= :
AwH zNb7SCOJoGO2AyaekYctgtD7AcQhfqWqWt75rwezL50GNOk9Y1pAjPc09gPw6/xkXeAqJEfExx0Up06qn2epSSsSAVsz8Y3PVmyp4h1i8wMQLjh2c3mvZv1OLaqCzac=
But I get a 500 internal server error. Does this have to do with the fact that the + has become a space? Why is that?
I have been struggling with this for hours. After this there are some more problems, but maybe if this is solved I'm able to solve those too. So this is my first question.
Hopefully someone here can help me with this!
Thank you in advance! :)