I found a similar thread https://laracasts.com/discuss/channels/laravel/encrypt-with-specific-key
Even though it's old, still a quick jump start is better than no info.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
What's a good way to encrypt/decrypt some data in a Laravel project using a custom key? Meaning, NOT the key in the key configuration option located in config/app.php? The use case of why I want to achieve this is to be able to encrypt and decrypt some data using a password that only I know, that no other administrator of the Laravel project will be able to decrypt and have access to.
Reading the documentation (https://laravel.com/docs/8.x/encryption), it doesn't seem to say anything about how to set a key other than the application's default one as the key to be used for encrypting and decrypting some data. When I search around on Google for it, I can't seem to find any information either. This seems to me like something that would be extremely simple and obvious to have some documentation for or an easy way to do, but apparently not.
Any help/insight to help me learn how I can achieve this is appreciated. Thank you.
Please or to participate in this conversation.