RSA解码的(phpseclib)JSON字符串引发错误3



im正在尝试解码通过RSA传输的JSON(PHPSECLIB)。这引发了JSON_ERROR_CTRL_CHAR。

$json_string = $rsa->decode($cyphertext);
$json_object = json_decode($json_string);

$json_string看起来像

{u0000"u0000ku0000eu0000yu0000"u0000:u0000"u0000Wu0000Zu0000gu0000...

json_last_error()返回3个

我做错了什么?

解决方案:

RSA解密将空字符放入消息中。您必须删除它们。

$json_string = $rsa->decode($ciphertext);  //decode my message
$json_string = str_replace("", "", $json_string); //replace null chars with "null" :D
$json_object = json_decode($json_string);  //decode json_string

最新更新