title: Exact alternate to mcrypt_encrypt in PHP 7.2
body: <p>Since mcrypt_encrypt is no longer supported in PHP 7.2, I am trying for exact alternate to this function. </p>
  
  <p>After reading many SO answers  I have found the following code which uses PHPSECLIB, but it's not producing the exact encrypted text as mcrypt. </p>
  
  <pre><code>function encryptRJ256($key,$iv,$string_to_encrypt)
      {
  
         // $rtn = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string_to_encrypt, MCRYPT_MODE_CBC, $iv);
  
        $rijndael = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CBC);  
        $rijndael-&gt;setKey($key);
        $rijndael-&gt;setIV($iv);
        $rijndael-&gt;setKeyLength(256);
        $rijndael-&gt;disablePadding();
        $rijndael-&gt;setBlockLength(256);
        $rtn = $rijndael-&gt;encrypt($string_to_encrypt);    
        $rtn = base64_encode($rtn);
        return($rtn);
      }
  </code></pre>
  
  <p>My Key and IV is</p>
  
  <pre><code>  $ky = 'lkirwf897+22#bbtrm8814z5qq=498j5'; 
  
    $iv = '741952hheeyy66#cs!9hjv887mxx7@8y';
  </code></pre>
  
  <p>The first 42 chars are equal but the rest is different as you can see </p>
  
  <p>Text to encrypt:          57F0-ECD3-1A3B-341E-BA39-F81B-F020-0DE0</p>
  
  <blockquote>
    <p><strong>mcrypt_encrypt output:</strong><br>
    3uw7mVZthiIPPNosvppZHd1jEau3Ul+0BQ4AVS2t80skauq3Zv9z5uztvmiBpYqQcKGIDP5YHfdEBhPBfdVbxg==</p>
    
    <p><strong>phpseclib output:</strong><br>
    3uw7mVZthiIPPNosvppZHd1jEau3Ul+0BQ4AVS2t80tKnjjxVhuAwh3E1S5OnH1up5AujvQu1Grgyv16tNIEDw==</p>
  </blockquote>
  
  <p>I need to produce the same encrypted text because this text is decrypted by another program which I can't change. </p>
  
  <p>So my question is, is it possible to produce the same encrypted text as mcrypt_encrypt using phpseclib or any other way?</p>