title: PHP 7.4 direct replacement for mcrypt decryption
body: <p>I have a legacy database with content that was encrypted with mcrypt using DES (yes, I know, it was a long time ago)
  The encryption method is like this:</p>
  <pre><code>/**
   * General encryption routine for generating a reversible ciphertext
   * @param String $string the plain text to encrypt
   * @param String $key the encryption key to use
   * @return String the cypher text result
   */
  function encrypt($string, $key)
  {
      srand((double) microtime() * 1000000);
      /* Open module, and create IV */
      $td = mcrypt_module_open('des', '', 'cfb', '');
      $ksub = substr(md5($key), 0, mcrypt_enc_get_key_size($td));
      $iv_size = mcrypt_enc_get_iv_size($td);
      $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
      /* Initialize encryption handle */
      if (mcrypt_generic_init($td, $ksub, $iv) != -1)
      {
          /* Encrypt data */
          $ctxt = mcrypt_generic($td, $string);
          mcrypt_generic_deinit($td);
          mcrypt_module_close($td);
          $ctxt = $iv . $ctxt;
          return base64_encode($ctxt);
      } //end if
  }
  </code></pre>
  <p>and the decryption method is like this:</p>
  <pre><code>/**
   * General decryption routine for recovering a plaintext
   * @param String $string the cypher text to decrypt
   * @param String $key the encryption key to use
   * @return String the plain text result
   */
  function decrypt($string, $key)
  {
      $ptxt = base64_decode($string);
      /* Open module, and create IV */
      $td = mcrypt_module_open('des', '', 'cfb', '');
      $ksub = substr(md5($key), 0, mcrypt_enc_get_key_size($td));
      $iv_size = mcrypt_enc_get_iv_size($td);
      $iv = substr($ptxt, 0, $iv_size);
      $ptxtsub = substr($ptxt, $iv_size);
      /* Initialize encryption handle */
      if (mcrypt_generic_init($td, $ksub, $iv) != -1)
      {
          /* Encrypt data */
          $ctxt = mdecrypt_generic($td, $ptxtsub);
          mcrypt_generic_deinit($td);
          mcrypt_module_close($td);
          return $ctxt;
      } //end if
  }
  </code></pre>
  <p>I need to extract this data in a PHP7.4 environment, even if only to re-encrypt it with something better, but I'm not sure how to reproduce the mcrypt operations with stuff that exists in PHP7.4 like sodium.
  I suppose one method would be to spin up some sort of legacy PHP installation that still has mcrypt and do it offline, but is there a more direct way of coding a decryption method?</p>