title: How to convert RSA key numbers into OpenSSL-compatible keys?
body: <p>I want to be able to generate private/public RSA keys with javascript only...</p>
  
  <p>So far I found <a href="http://www.hanewin.net/encrypt/rsa/rsa.htm" rel="nofollow noreferrer">http://www.hanewin.net/encrypt/rsa/rsa.htm</a>, it includes the only Javascript RSA key generator I found. I created wrappers (modifying the code from the demo page (see link)), here's the one for the keys:</p>
  
  <pre><code>function genKeys() {
   rsaKeys(1024);
   var p=rsa_p;
   var q=rsa_q;
   var d=rsa_d;
   var u=rsa_u;
   var e=rsa_e;
   var pq=rsa_pq;
  
   return {"e": e, "p": p, "q": q, "pq": pq, "d": d, "u": u};
  }
  </code></pre>
  
  <p>The problem with it is that the output is given as the actual numbers (exponent, modulus, etc.), but I need the key in the OpenSSL format (the base64 encoded thing). Can someone tell me what the format of the OpenSSL key data is, or even better - how do I convert a key generated with the code from that site into a OpenSSL key?</p>
  
  <p>I want to use the result with pidcrypt (a js crypto library) and ruby/openssl...</p>
  
  <p>Thank you very much for any suggestion...</p>