title: RSA decryption using private key
body: <p>I have a private key and encrypted string. Actually string has been encrypted using .NET modules. Now I need to decrypted the string . I tried in php but it throws me following error</p>
  
  <pre><code> openssl_private_decrypt(): key parameter is not a valid private key  
  </code></pre>
  
  <p>I tried in perl but  there it takes its own private key, But it need to use my own private key, which  has been generated  in our server. </p>
  
  <p>Please suggest me on this issue to overcome. PHP ,Ruby , Perl Solution would be more helpful.</p>
  
  <pre><code>$crypttext="gKL/n5hkBg4jyjrLRqjQbf9gAS3xnbp1xmCmamPO33fW21JAJtlVQHYR6O1dOw3tfobMe/0uXm/kgivae9zHNey4Wt3UGzPwosUrx7V8zhC97AXya2tuENO1Fmc4Z8l9+UalwtUZxMGtl3Ua9DYuvxLP/TuavgRNpmG6eemGPag=";
  $fp=fopen("private.pem","r");
  $priv_key=fread($fp,8192);
  fclose($fp);
  openssl_private_decrypt(base64_decode($crypttext ),$newsource,false ) ;
  echo "String decrypt : $newsource"**;
  </code></pre>
  
  <p><strong>Private Key</strong></p>
  
  <pre><code>&lt;BitStrength&gt;1024&lt;/BitStrength&gt;&lt;RSAKeyValue&gt;&lt;Modulus&gt;t2G2WWIal1EinPn54ZPc3S1UgGTDxr6RFc+XEMR723VSg9toU8lSfTD7C26bUcbDxBwP1/1MbdQcx/dKX+7UlB5z79vrwfT89rUZGWeH7VZvuAawtHURgucyGMhqAZ9NxDEAl5Uo3nsNL9j1JlSBfeZf8pU5sf70KezqJTRsfrE=&lt;/Modulus&gt;&lt;Exponent&gt;AQAB&lt;/Exponent&gt;&lt;P&gt;82dZbOjQCJ7NV6EuVJXqPlh4FB65LBL1w9696sKFZuIr8refGwTZOY05se6oHbT9mn8OFXVA6A/wmz7oWNPk9w==&lt;/P&gt;&lt;Q&gt;wN8uixNk73DIF2SHb0aunnW5XxAIq3KxeQKoUTBAzL7BqXmKjk6XDnfxDbybmcT51wGhiO20lGg51zuxnsPXlw==&lt;/Q&gt;&lt;DP&gt;Kv4+VXZqCJvEOY5G2LoCPjDyRNuIabiPoKFfenARkDKzAJReji81D21am4tENrsZcIiwvCmR5WurXECoWchT0Q==&lt;/DP&gt;&lt;DQ&gt;qGRzW4O0VYVvfVUNFi9tF/aKwR/boe0CXDfgwvnRKbHGnfP67+JX6o73zFmGtQuQYpMO+OEpD4WsMmnw2z/7ww==&lt;/DQ&gt;&lt;InverseQ&gt;czq4+xiiVxb63ZtKwkxyJoDLFH0f18YlfFQTrEoAx7UE9HdjOjsJFpZ54g0yK3/S/yVgIXPwMcw6LU1QvqazPg==&lt;/InverseQ&gt;&lt;D&gt;Ktp/tWWSlzfToeFcvpVCMMGOFK73fTM9Tl6Di9yOoRtKnBuixqmuSCkxEVvYmgSb7PEt1qiPur6ttyEX1VFHhaugTr3aVhUpF+k7ULaHrCb8UymXXW3pp/yl/QOMPWuNKVv/GU3aQ3VTc3WUaYuOnaIkJk7uoYDQn0QqWtxtT60=&lt;/D&gt;&lt;/RSAKeyValue&gt;
  </code></pre>