title: Decryption of encrypted text in PHP
body: <p>I am trying to decode encrypted data in PHP, however the return value keeps coming back as null.</p>
  
  <p>The data to be decrypted comes into the PHP file as a data argument.</p>
  
  <pre><code>$dataArg1 = $_REQUEST["data"];
  
  // Retrieve $encryptedData from storage ...
  //
  // Load the private key and decrypt the encrypted data
  $encryptedData = $dataArg1;
  $privateKey = array ( array(123456,654321,123456), array(123456,1234),
                        array(1234567,4321)
                      );
      openssl_private_decrypt($encryptedData, $sensitiveData, $privateKey);
  </code></pre>
  
  <p>The function above comes from the second response of another posting here on Stack Overflow:
  <a href="https://stackoverflow.com/questions/2414064/how-to-encrypt-data-in-javascript-and-decrypt-in-php">How to encrypt data in javascript and decrypt in php?</a></p>
  
  <p>I assume that the decrypted value is in the PHP variable, $sensitiveData.</p>
  
  <p>When I echo that to the screen, I get nothing.</p>
  
  <pre><code>echo("sensitiveData=[$sensitiveData]&lt;br /&gt;");
  </code></pre>
  
  <p>Thoughts?</p>
  
  <p>UPDATE:
  The return value from openssl_private_decrypt() is FALSE, and the return value is NULL.</p>
  
  <p>UPDATE 2:
  I created the public/private key from the following URL.
  <a href="http://shop-js.sourceforge.net/crypto2.htm" rel="nofollow noreferrer">http://shop-js.sourceforge.net/crypto2.htm</a></p>
  
  <p>At the bottom, there is the line:
      And put the following in your private script (probably on your local hard disk -- not on the internet -- if your private key is found this whole thing is useless.)</p>
  
  <pre><code>&lt;script&gt;
  function decrypt() {
   // key = [ [d], [p], [q] ];
   var key=[[123456789,123456789,123456789],[123456789,1234],[123456789,4321]];
   document.form.text.value=rsaDecode(key, document.form.text.value);
  }
  &lt;/script&gt;
  (actual values changed)
  </code></pre>
  
  <p>I copied translated the "var key=" line to PHP (per my other posting).  Translation above using embedded arrays.  I then past that key to the decrypt function.</p>
  
  <p>My thought is that the PHP documentation calls the private key "mixed".  I am wondering if maybe I need a different format for the private key.</p>
  
  <p>Here is the output:</p>
  
  <pre><code>dataArg1=[jmOdss9ktFc\"WO5eltUZXt0rpqS1NluNKa]
  
  bResult=[]
  
  sensitiveData=[]
  
  var_dump=[NULL ]
  </code></pre>