title: Sodium Crypto box seal open not working in PHP
body: <p>So I'm trying to get libsodium's <a href="http://php.net/manual/en/function.sodium-crypto-box-seal.php" rel="nofollow noreferrer"><code>sodium_crypto_box_seal</code></a> and <a href="http://php.net/manual/en/function.sodium-crypto-box-seal-open.php" rel="nofollow noreferrer"><code>sodium_crypto_box_seal_open</code></a> working but for some reason, the open is failing and I can't work out why.</p>
  
  <p>So in all my trying to get this working, I have built a test system that a single PHP file that tests how it would work cross server.</p>
  
  <pre><code>&lt;pre&gt;
  &lt;?php
  /*** Client Sending ***/
  // saved argument
  $remotePublic = "DXOCV4BU6ptxt2IwKZaP23S4CjLESfLE+ng1tMS3tg4=";
  
  // create out key for this message
  $key = sodium_crypto_box_keypair();
  
  // encrypt our message using the remotePublic
  $sealed = sodium_crypto_box_seal("This is a test", base64_decode($remotePublic));
  $send = json_encode((object)array("pub" =&gt; base64_encode(sodium_crypto_box_publickey($key)), "msg" =&gt; base64_encode($sealed)));
  echo "Sending : {$send} \r\n";
  
  /*** Server Setup ***/
  $payload = json_decode($send);
  $apps = 
  array (
    'test' =&gt; 
    array (
      'S' =&gt; 'lv/dT3YC+Am1MCllkHeA2r3D25HW0zPjRrqzR8sepv4=',
      'P' =&gt; 'DXOCV4BU6ptxt2IwKZaP23S4CjLESfLE+ng1tMS3tg4=',
    ),
  );
  
  /*** Server Opening ***/
  $msg = $payload-&gt;msg;
  $key = sodium_crypto_box_keypair_from_secretkey_and_publickey(base64_decode($apps['test']['S']), base64_decode($apps['test']['P']));
  $opened = sodium_crypto_box_seal_open(base64_decode($msg), $key);
  echo "Opened : {$opened} \r\n";
  
  /*** Server Responding ***/
  $sealedResp = base64_encode(sodium_crypto_box_seal("We Got your message '{$opened}'", base64_decode($payload-&gt;pub)));
  echo "Responding : {$sealedResp}\r\n";
  
  /*** Client Receiving ***/
  $received = sodium_crypto_box_seal_open(base64_decode($sealedResp), $key);
  echo "Received : {$received}\r\n";
  
  /*** Sanity Checking ***/
  if($received == "We Got your message 'This is a test'"){
      echo "Test Successfull.\r\n";
  }else{
      echo "Test Failed got '{$received}' is not \"We Got your message 'This is a test'\"\r\n";
  }
  ?&gt;
  &lt;/pre&gt;
  </code></pre>
  
  <p>Output is:</p>
  
  <pre><code>Sending : {"pub":"DS2uolF5lXZ1E3rw0V2WHELAKj6+vRKnxGPQFlhTEFU=","msg":"VVYfphc2RnQL2E8A0oOdc6E\/+iUgWO1rPd3rfodjLhE+slEWsivB6QiaLiMuQ31XMP\/1\/s+t+CSHu8QukoY="} 
  Opened : This is a test 
  Responding : cvDN9aT9Xj7DPRhYZFGOR4auFnAcI3qlwVBBRY4mN28JmagaR8ZR9gt6W5C0xyt06AdrQR+sZFcyb500rx6iDTEC4n/H77cUM81vy2WfV8m5iRgp
  Received : 
  Test Failed got '' is not "We Got your message 'This is a test'"
  </code></pre>