title: Encrypt in Javascript, decrypt in PHP, using public-key cryptography
body: <p>I'd like to encrypt in JavaScript, decrypt in PHP, using public-key cryptography. I've been trying to find libraries that can accomplish this, but am having issues.</p>
  
  <p><strike>I am currently looking at <a href="http://openpgpjs.org/" rel="noreferrer">openpgpjs</a>, but I need support in all browsers, and even the test page has errrors on the only listed as supported browser (Google Chrome).</strike></p>
  
  <p>Notes about the final goal:</p>
  
  <p><strong>The TCP connection is already protected by SSL. The main purpose of this layer of protection is defending against intentional or unintentional webserver logging, crash dumps, etc.</strong></p>
  
  <p>On the PHP side, a temporary private key will be generated (it will expire after a short time). The caller (in Javascript) is responsible for asking for a new public key when it expires. The reason for private key expiration is to prevent logged encrypted data decryption, in case the server which stores the private key is later compromised.</p>
  
  <p>Servers compromised scenario: someone gets his hands on backups for all machines except the database server (and cannot access the database due to firewalling, even if he finds out the user and password). Since the private key which encrypted the logged data no longer exists, there is nothing the attacker can do.</p>