title: Convert mcrypt used in PHP to Node.js
body: <p>I want to convert this code to Node.js:</p>
  <pre><code>&lt;?php
  $str = 'test';
  $key = 'aaaaaaaaaaaaaaaaaaaaaaaa';
  $td = mcrypt_module_open(MCRYPT_TripleDES, '', MCRYPT_MODE_ECB, '');
  $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
  mcrypt_generic_init($td, $key, $iv);
  $ret = mcrypt_generic($td, $str);
  mcrypt_generic_deinit($td);
  mcrypt_module_close($td);
  $ret = base64_encode($ret);
  echo($ret);
  </code></pre>
  <p>output: 7YM5liyGmBs=</p>
  <p>Coded like this with Node.js:</p>
  <pre><code>const crypto = require('crypto')
  
  const str = 'test'
  const key = 'aaaaaaaaaaaaaaaaaaaaaaaa'
  const iv = ''
  const cipher = crypto.createCipheriv('des-ede3', key, iv)
  let res = `${cipher.update(str, 'utf8', 'base64')}${cipher.final('base64')}`
  console.log(res)
  </code></pre>
  <p>output: kSSvwld1yDA=</p>
  <p>Why is the output different, and how should I code it in Node.js?</p>