我对此很陌生。我的 PHP 回声返回垃圾。我认为我缺少一个编码步骤。
我的 OBJ-C 代码
NSString *key = @"12345678901234561234567890123456";
//main path for account login PHP file
NSString *accountURL = [NSString stringWithFormat:configManager.accountURL, username, password];
//convert password to data and encrypt
NSData *crypt = [[[password stringValue]dataUsingEncoding:NSUTF8StringEncoding]AES256EncryptWithKey:key];
NSString *variables = [NSString stringWithFormat:@"?username=%@&access=%@&page=%ld",[username stringValue], crypt, [sender tag]];
// get rid of spaces in encoded URL
NSString *niceURLString = [variables stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//tack niceURL on to end of base URL
NSString *goToURL = [accountURL stringByAppendingString:niceURLString];
NSLog(@"%@", goToURL);
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:goToURL]];
PHP
$upswd = $_GET['access'];
$key = "12345678901234561234567890123456";
$upswd = trim($upswd, "<>"); //remove these brackets from url
$result = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $upswd, 'ecb');
//$result = utf8_decode($result);
echo ($result);