title: PHP 7.2 : Replace mcrypt method "mcrypt_get_iv_size"
body: <p>I've updated my existing system to PHP 7.4 and mcrypt has been removed and I'm looking for an alternative.<br />
  It's recommended to change the code using openssl, but I didn't see any articles posted in my case.<br />
  It is recommended to rewrite <code>mcrypt_create_iv</code> for <code>random_bytes</code> and <code>mcrypt_ecb</code> for <code>mcrypt_encrypt</code>, but there is no alternative to E and I can't think of that rewrite.<br />
  Do you have an idea?</p>
  <p>Service.php</p>
  <pre class="lang-php prettyprint-override"><code>    /**
       * 3DES encryption
       *
       * @param string $plain Plaintext
       * @return string cipher Ciphertext
       */
      public function encrypt3DES($plain) {
          $iv  = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_3DES, MCRYPT_MODE_ECB), MCRYPT_RAND);
          $cipher = bin2hex(mcrypt_ecb (MCRYPT_3DES, self::AUTH_KEY, $plain, MCRYPT_ENCRYPT, $iv));
          return $cipher;
      }
  
      /**
       * 3DES decryption
       *
       * @param string $cipher Ciphertext
       * @return string Plaintext
       */
      public function decrypt3DES($cipher) {
          if (!ctype_xdigit($cipher)) {
              return '';
          }
  
          $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_3DES, MCRYPT_MODE_ECB), MCRYPT_RAND);
          $plain = mcrypt_ecb(MCRYPT_3DES, self::AUTH_KEY, pack(&quot;H*&quot;, $cipher), MCRYPT_DECRYPT, $iv);
  
          return trim($plain);
      }
  </code></pre>