phpseclib/mcrypt_compat
PHP 5.x–8.x polyfill for the deprecated mcrypt extension. Provides common ciphers (Rijndael/AES variants, DES, Blowfish, RC2, 3DES, ARCFOUR) and modes (CBC, CFB, CTR, ECB, OFB, stream). Can emulate older PHP mcrypt behavior.
mcrypt extension to PHP 8.x without rewriting core encryption logic, critical for monoliths or systems with hardcoded mcrypt dependencies.mcrypt in internal tools or third-party dependencies, reducing technical debt and aligning with Laravel’s long-term PHP 8.x+ strategy.rijndael-256, tripledes) or compliance-heavy environments requiring exact legacy behavior.mcrypt calls (e.g., custom encryption layers, legacy database fields).mcrypt (e.g., outdated payment gateways, legacy authentication).mcrypt extension is unavailable (e.g., Docker containers, PHP 8.x without extensions).Adopt if:
mcrypt in PHP 5.x–8.x and cannot immediately upgrade dependencies or rewrite encryption logic.rijndael-256, ncfb, tripledes) not covered by alternatives like openssl or defuse/php-encryption.mcrypt extension is impractical.Look elsewhere if:
openssl or sodium (recommended for new Laravel projects).gost, serpent, cast-128), which require custom implementations.openssl is ~10–100x faster).mcrypt entirely (it’s deprecated and insecure by modern standards).Illuminate\Encryption\Encrypter), which already leverages openssl and is the recommended long-term solution.For Executives:
*"This package allows us to modernize legacy Laravel systems without rewriting encryption logic, saving an estimated [X] months of development time and avoiding [Y] dollars in operational risks. By using mcrypt_compat, we can:
mcrypt dependencies, aligning with our roadmap to drop PHP 7.x support by [date].mcrypt.
It’s a low-risk, short-term solution that buys us time to transition to openssl-based encryption long-term."For Engineering Teams:
*"mcrypt_compat is a drop-in replacement for the deprecated mcrypt extension, supporting all our legacy algorithms (e.g., rijndael-256, tripledes, ncfb) in PHP 8.x. Here’s how we’ll use it:
extension=mcrypt in php.ini with composer require phpseclib/mcrypt_compat—no runtime errors.mcrypt functions in Laravel’s service container to abstract the polyfill (e.g., \mcrypt_encrypt = \phpseclib\mcrypt_compat\mcrypt_encrypt).ncfb mode and PHP version emulation (e.g., define('PHPSECLIB_MCRYPT_TARGET_VERSION', '5.3.0')) for legacy systems.openssl.Illuminate\Encryption (which uses openssl).mcrypt_compat with openssl-based solutions in [QX 2024].Tradeoffs: It’s not a permanent fix (we’ll eventually move to openssl), but it’s the fastest way to unblock our migration."*
For Security Teams:
*"While mcrypt is deprecated, mcrypt_compat replicates its behavior exactly, including edge cases like padding and mode-specific quirks. We’ll use it to:
mcrypt usage for weak algorithms (e.g., DES, Blowfish) and prioritize replacements.phpseclib is generally robust).openssl or sodium (via Laravel’s Encrypter)."*How can I help you explore Laravel packages today?