title: Encrypt/decrypt JSON data in NodeJS
body: <p>I have a server with endpoint that sends data which gets received by a different server, both running NodeJS - and I wanted it so that the JSON data which gets sent is encrypted, so I looked into node-rsa, but as I am new to Node in general, it felt a little cryptic for me. </p>
  
  <p>I tried the initial functionality of encrypting the data being sent, but after it reaches my second server, I would like it to only be decrypted there so it can be parsed properly, but I don't quite get how to decrypt it. </p>
  
  <p>The code for my encryption is supposedly like this:</p>
  
  <pre><code>const encrypted = key.encrypt(data, 'base64');
  res.json({
              status: 200,
              message: "Done",
              data: encrypted;
          });
  </code></pre>
  
  <p>How do I exactly go on making a key-pair using node-rsa to decrypt the output of the data sent? And I suppose the best practice would be to make the actual key in a .env file instead hard-coding it into the code?</p>