Я пытаюсь выяснить проблему с PHP-скриптом, который я пишу. По сути, этот скрипт использует phpseclib library для шифрования пароля с использованием открытого ключа RSA, переданного ему приложением ASP.NET. Кажется, что пароль зашифрован отлично, но когда я пытаюсь поместить зашифрованную строку в строку json, она превращается в NULL.PHP json_encode turn string to null
Код:
// Create our RSA encryption object
$rsa = new Crypt_RSA();
// Get modulus and exponent for our public key
// ($keyInner was gathered from the keygen server)
$modulus = new Math_BigInteger(base64_decode($keyInner->{'Modulus'}), 256);
$exponent = new Math_BigInteger(base64_decode($keyInner->{'Exponent'}), 256);
// Generate our public key and padding scheme
$rsa->loadKey(array('n' => $modulus, 'e' => $exponent));
$rsa->setPublicKey();
$rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1);
// Gather user data
// In reality this is gathered from a form but for
// example's sake I'll be using static values
$username = 'foo';
$password = 'boo';
// Encrypt password
$password = $rsa->encrypt($password);
// $password == <some encrypted string>
// gettype($password) == string
// mb_detect_encoding == UTF_8
// Create json
$arr = json_encode(array(
'payload' => array(
'username' => $username,
'password' => $password,
)
));
// $arr = {"payload":{"username":"Bob","password":null}}
@ RyanVincent делает то, что 1) он работает по https и 2) это внутреннее изменение приложения? –