pierrre/encrypter-bundle
A Symfony bundle that provides an injectable encrypter service for encrypting and decrypting strings with a configurable secret key. Add it to your app to protect sensitive values without writing low-level crypto code yourself.
pierrre/encrypter-bundle is a Symfony2 bundle from the Symfony 2.x era. It ships a Bundle class, an Extension, and DI config — none of which Laravel's service container autoloads. Before writing any code, decide whether you're actually consuming it inside an old Symfony app (where it's a drop-in) or trying to graft it into Laravel (where you should almost certainly use Laravel's built-in Crypt facade instead).mcrypt, and OpenSSL-based ciphers may be the only ones still functional.DependencyInjection/Configuration.php — tells you the exact config keys (typically a key, plus cipher/mode/algorithm-style options).DependencyInjection/PierrreEncrypterExtension.php — shows the service ID it registers and how the key is injected.README.md — the config example is usually the fastest path to a working setup.AppKernel.php, put the key in parameters.yml (never committed), point pierrre_encrypter.key at it, then inject the service (commonly pierrre_encrypter.encrypter) into whatever needs it.encrypt() → decrypt() with a known key before wiring it into anything real; this immediately tells you whether the cipher your PHP build lacks is the one it defaults to.prePersist/preUpdate subscriber that encrypts designated fields and a postLoad that decrypts them. Keep the field list in one place (an entity attribute or a config map) so you don't scatter encrypt() calls across controllers.VARCHAR(255) is a classic truncation bug.config('app.key') and the Crypt facade — the bundle's value here is mostly as a pattern reference.EncrypterInterface with encrypt(string): string / decrypt(string): string and have the bundle's service implement or be adapted to it. When the bundle inevitably can't be upgraded, you replace one adapter instead of hunting call sites.v1:) so a future key rotation or cipher change can be handled by branching on the prefix at read time. The bundle gives you raw bytes; the versioning is your job.Crypt::encryptString() / decryptString() for payloads, Hash::make() for passwords (never the encrypter), and encrypted casts on Eloquent models. The equivalent "bundle" is already in the framework.mcrypt (likely given its Symfony2 vintage), it will hard-fail on PHP 7.2+; if it uses OpenSSL with a CBC-mode cipher, it may lack authentication (no MAC/AEAD), leaving ciphertext malleable. Verify which mode you're on before trusting it.rijndael-256/cbc that no modern PHP build provides. Set the cipher explicitly to something your runtime actually supports (e.g. aes-256-cbc, ideally aes-256-gcm) and test decrypt with the exact same config.APP_KEY, this bundle likely wants the literal key string. Mismatched encoding is the number-one cause of "decrypts to garbage" — the operation succeeds but returns wrong bytes, so it fails silently rather than throwing.encrypt() calls on the same input will differ and that's correct. Write a test that asserts decrypt(encrypt($x)) === $x and a second that asserts a wrong key throws or returns a distinguishable failure.app/console cache:clear).Crypt. Don't add an archived Symfony2 bundle to a Laravel project — you'd be pulling in a second container, an unmaintained cipher layer, and a transitive dependency risk for functionality Laravel already ships.How can I help you explore Laravel packages today?