title: PKCS7 encrypt decrypt in Node.js
body: <p>I am using pkcs7 encrypt decrypt in current project. I want to change from PHP to Node.js. Is there pkcs7 encrypt/decrypt in Node.js ? </p>
  
  <p>In PHP,</p>
  
  <pre><code>&lt;?php
  
  $data = &lt;&lt;&lt;EOD
  Hello world
  EOD;
  
  // load key
  $key = file_get_contents("mypublickey.crt");
  
  // save message to file
  $fp = fopen("msg.txt", "w");
  fwrite($fp, $data);
  fclose($fp);
  
  // encrypt it
  if (openssl_pkcs7_encrypt("msg.txt", "enc.txt", $key,array())) {
      // message encrypted - send it!
  
  }
  ?&gt;
  </code></pre>
  
  <p>to decrypt</p>
  
  <pre><code>&lt;?php
  // The certification stuff
  $public = file_get_contents("mypublickey.crt");
  $private = array(file_get_contents("myprivatekey.pem"), "mypassword");
  
  $infile = tempnam("", "enc");
  file_put_contents($infile, $encrypted); 
  $outfile = tempnam("", "dec");
  
  if(openssl_pkcs7_decrypt("enc.txt", "dec.txt", $public, $private))
  {
      // Decryption successful
      echo file_get_contents("dec.txt");
  }
  ?&gt;
  </code></pre>
  
  <p>Is there any similar function like this in Node.js ?</p>