sumeetghimire / encrypt-decrypt-with-key
A Laravel package for encrypting and decrypting strings with a key (Fixed: Prevents repeated key generation)
1.0.5
2025-08-10 05:51 UTC
Requires
- php: ^8.1
- laravel/framework: ^10.0|^11.0|^12.0
README
EncryptDecryptWithKey
Laravel EncryptDecryptWithKey Package - Version 1.0.5
🚀 Key Generation Fix
Fixed Issue: The package was previously generating new encryption keys on every request, which caused performance issues and potential data corruption.
What was fixed:
- Added key caching to prevent repeated environment variable reads
- Improved service provider to only generate keys once during installation
- Enhanced error handling and key validation
Configuration
You can customize the package configuration by modifying the config/encrypt-decrypt.php
file.
License
The Laravel EncryptDecryptWithKey package is open-sourced software licensed under the MIT license.
Support
For any issues or suggestions, please open an issue on GitHub.
Credits
This package is maintained by Sumeet Ghimire.
Laravel
Require this package in your composer.json
and update composer.
composer require sumeetghimire/encrypt-decrypt-with-key
Example How to use
use SumeetGhimire\EncryptDecryptWithKey\EncryptionHelper;
$encryptedString = EncryptionHelper::encryptString('test');
$decryptedString = EncryptionHelper::decryptString($encryptedString);
return $decryptedString; // Returns 'test'
Key Management
- Automatic Generation: The package will automatically generate a secure key if none exists
- Key Caching: Keys are cached in memory for performance
- Key Rotation: Use
EncryptionHelper::clearCache()
to clear cached keys when rotating
In .env key will be auto generated change as per your requirement
ENCRYPT_KEY=8141b227d15377e8249b4c2cd42df4a7