title: NodeJS, RSA, is this secure?
body: <p>Is this a secure way of encrypting with a public key and decrypting with the private?</p>
  
  <p>If not, what do I need to add?  A pass of AES or similar?</p>
  
  <pre><code>var ursa = require('ursa');
  var fs = require('fs');
  
  // create a pair of keys (a private key contains both keys...)
  var keys = ursa.generatePrivateKey();
  console.log('keys:', keys);
  
  // reconstitute the private key from a base64 encoding
  var privPem = keys.toPrivatePem('base64');
  console.log('privPem:', privPem);
  
  var priv = ursa.createPrivateKey(privPem, '', 'base64');
  
  // make a public key, to be used for encryption
  var pubPem = keys.toPublicPem('base64');
  console.log('pubPem:', pubPem);
  
  var pub = ursa.createPublicKey(pubPem, 'base64');
  
  // encrypt, with the public key, then decrypt with the private
  var data = new Buffer('hello world');
  console.log('data:', data);
  
  var enc = pub.encrypt(data);
  console.log('enc:', enc);
  
  var unenc = priv.decrypt(enc);
  console.log('unenc:', unenc);
  </code></pre>