0

我一直在尝试在 iPhone 应用程序和 PHP Web 服务之间实现一些加密。但是它不起作用。似乎文本的前半部分没有被解密,而后半部分被解密得很好。我应该怎么办?

PHP加密方法如下:

function decrypt($str, $iv) {
    $iv .= "00000000";
    $str = base64_decode($str);
    return self::decrypt_data($str, $iv, self::secret_key);
}

加密文本的 iPhone 使用 CryptoHelper 类,如下所示:

NSString *encrypted = [[CryptoHelper sharedInstance] encryptString:dataString];

CryptoHelper 类可以在http://pastie.org/1267796看到。

4

1 回答 1

1

Try a simple example where you send a known Base64 encoded string from the iPhone app to PHP.

Compare the known valid string to what PHP is getting. I know recently, when trying to do an Ajax post from a script to PHP, we were having trouble with some characters (specifically +) being converted to spaces by PHP because it was doing a URL decode automatically. We had to switch all + to their % (URL-encoded %2B) equivalent. This fixed the problem for us.

于 2010-11-02T21:43:12.090 回答