Download the PHP package bespredel/encryption-form without Composer
On this page you can find all versions of the php package bespredel/encryption-form. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bespredel/encryption-form
More information about bespredel/encryption-form
Files in bespredel/encryption-form
Package encryption-form
Short Description A Laravel package to securely encrypt form fields on the client-side using public key encryption and decrypt them on the server-side using the private key.
License MIT
Informations about the package encryption-form
EncryptionForm - Secure Client-Side Form Encryption
🔐 Protect sensitive form data before it leaves the browser
EncryptionForm is a lightweight solution for encrypting form data on the client side before sending it to the server.
It helps protect sensitive information such as passwords, personal data, and confidential inputs from interception.
✨ Features
- RSA Encryption: Uses
JSEncryptfor secure RSA encryption. - HTML Attribute Control: Specify which fields to encrypt using
data-encrypt="true". - Flexible Form Encryption: Target specific forms using
data-encrypt-formattribute. - Blade Directive: Automatically inject encryption scripts with
@encryptFormScripts. - Simple Key Management: Easily configure keys via
.envor generate new keys via artisan commands. - Zero Dependencies: No NPM required; all scripts are included in the package.
🚀 Use Cases
- Login & authentication forms
- Payment / sensitive input fields
- Personal data collection forms
- Secure admin panels
- API request protection
🧠 How It Works
- User fills the form
- Data is encrypted in the browser
- Encrypted payload is sent to server
- Server decrypts the data
- Application processes secure input
📦 Installation
-
Install the Package:
-
Publish Config and Scripts:
-
Add RSA Keys to :
If you don't have keys, you can generate them using the following commands:
- Include the Blade Directive in Your Template:
Add
@encryptFormScriptsto your layout file or specific views where forms are encrypted.
🚀 Usage
Middleware
For auto decryption of form data, add the DecryptRequestFields middleware to your Kernel:
or use it in a route:
HTML Form Example
In your Blade template:
- Add
data-encrypt-formto the<form>tag to enable encryption for this form. All supported form fields will be encrypted.- Use
data-encrypt="true"for fields that require encryption. All other fields will not be encrypted. - Use
data-encrypt="false"for fields that do not require encryption. All other fields will be encrypted.
- Use
Types of Fields Available for Encryption:
-
Input Fields:
- Supported types:
text,email,password,number,date, and similar. - Exceptions:
file,checkbox,radio,select.
- Supported types:
- Textarea:
- Fully supported.
!!! It is important to note that the encrypted value will be longer than the original value, which may affect data length constraints.
Manual decrypting data on the server
Use the Decryptor class to decrypt data on the server:
Or use dependency injection:
Or use the openssl_private_decrypt function to decrypt data on the server:
⚡ Commands
Generate New RSA Keys
To generate a new pair of RSA keys:
This will update the keys in your .env file.
Keys are saved as escaped multiline values to keep the .env file parse-safe.
⚙️ Configuration
Config File:
Quality checks
Key Rotation via Scheduler
You can schedule automatic key rotation via the key_rotation key in the config file.:
🤝 Contributing
- Fork the repository.
- Create your feature branch:
git checkout -b feature/my-feature. - Commit your changes:
git commit -m 'Add some feature'. - Push to the branch:
git push origin feature/my-feature. - Open a pull request.
🛡 Security
PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
🙏 Acknowledgements
I would like to thank the authors and contributors of the JSEncrypt library for providing a secure RSA encryption solution for client-side data encryption.
📄 License
This package is open-source software licensed under the MIT license.
⭐ Support
If you find this project useful, give it a star ⭐