mcrypt_encrypt to openssl_encrypt, and OPENSSL_ZERO_PADDING problems
<p>I have this <code>mcrypt_encrypt</code> call, for a given <code>$key</code>, <code>$message</code> and <code>$iv</code>:</p>
<pre><code>$string = mcrypt_encrypt(MCRYPT_3DES, $key, $message, MCRYPT_MODE_CBC, $iv);
</code></pre>
<p>I'd like to change the <code>mcrypt_encrypt</code> call to an <code>openssl_encrypt</code> one, to future-proof this.</p>
<p>By having <code>$mode = 'des-ede3-cbc'</code> or <code>$mode = '3DES';</code> and <code>$options = true</code> I get the more similar response, but not identical. Is there other way to call it to get a perfect match?</p>
<p>I am getting this (base64_encoded) for a lorem-ipsum <code>$message</code>+<code>$key</code> combinations, so I am starting to believe one function or the other are padding somewhat the message before encrypting...</p>
<p>for mcrypt:</p>
<blockquote>
<p>&quot;Y+JgMBdfI7ZYY3M9lJXCtb5Vgu+rWvLBfjug2GLX7uo=&quot;</p>
</blockquote>
<p>for for openssl:</p>
<blockquote>
<p>&quot;Y+JgMBdfI7ZYY3M9lJXCtb5Vgu+rWvLBvte4swdttHY=&quot;</p>
</blockquote>
<p>Tried using <code>$options</code> to pass <em>OPENSSL_ZERO_PADDING</em>, but passing anything but <strong>1</strong> (<em>OPENSSL_RAW_DATA</em>, or <em>true</em>)  results in an empty string ...</p>
<p>Neither using <code>OPENSSL_ZERO_PADDING</code> nor <code>OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING</code> work... :(
I'm using &quot;OpenSSL 1.0.2g  1 Mar 2016&quot;.</p>
<p>Already read <a href="https://stackoverflow.com/questions/18102056/php-openssl-equivilent-of-mcrypt-mcrypt-3des">this</a> q&amp;a, but it does not help me. Not the <a href="https://stackoverflow.com/questions/9993909/php-replace-mcrypt-with-openssl?rq=1">only</a> <a href="https://stackoverflow.com/questions/9186541/why-does-something-encrypted-in-php-not-match-the-same-string-encrypted-in-ruby?rq=1">one</a> with padding troubles, but no solution in sight so far. Second answer talks about <strong>adding</strong> padding to mcrypt call, I would really want to <strong>remove</strong> padding from openssl encryption call...</p>