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 Encrypt form fields with public key before sending to server
License MIT
Informations about the package encryption-form
Encryption Form
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. This package integrates seamlessly with Laravel Blade templates and requires minimal configuration.
Features
- RSA Encryption: Uses
JSEncrypt
for secure RSA encryption. - HTML Attribute Control: Specify which fields to encrypt using
data-encrypt="true"
. - Flexible Form Encryption: Target specific forms using
data-encrypt-form
attribute. - Blade Directive: Automatically inject encryption scripts with
@encryptFormScripts
. - Simple Key Management: Easily configure keys via
.env
or generate new keys via artisan commands. - Zero Dependencies: No NPM required; all scripts are included in the package.
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
@encryptFormScripts
to 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-form
to 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 RequestDecryptor
class to decrypt data on the server:
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.
Configuration
Config File:
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.