title: Public encryption in crypto on node 0.12
body: <p>I need to encrypt (and decrypt) a string with a public key previously generated in nodejs (i'm using version 0.12) with crypto module, but i'm unable to do it.</p>
  
  <p>For first i generated the keys in this way:</p>
  
  <pre><code>var diffHell = crypto.createDiffieHellman(60);
  diffHell.generateKeys('base64');
  var publicKey = diffHell.getPublicKey('base64'); //or whatever 'hex','binary'
  var privateKey = diffHell.getPrivateKey('base64'); //or whatever 'hex','binary'
  </code></pre>
  
  <p>Then i tried to encrypt a string using the generated public key:</p>
  
  <pre><code>crypto.publicEncrypt({key: publicKey}, new Buffer(textToEncrypt));
  </code></pre>
  
  <p>Running this snippet, node throw this error:</p>
  
  <pre><code>Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
      at Error (native)
      at Object.exports.publicEncrypt (crypto.js:362:18)
      [...]
  </code></pre>
  
  <p>Reading it, I understand that the key must be in PEM format, but i can't find in the documentation how to tranform a public key in PEM.</p>
  
  <p>So, How i can do that? Someone has done this yet?</p>