Download the PHP package hamoi1/eloquent-encryptable without Composer
On this page you can find all versions of the php package hamoi1/eloquent-encryptable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hamoi1/eloquent-encryptable
More information about hamoi1/eloquent-encryptable
Files in hamoi1/eloquent-encryptable
Package eloquent-encryptable
Short Description This package provides a way to encrypt and decrypt the data in the database using the Hill Cipher algorithm.
License MIT
Informations about the package eloquent-encryptable
Eloquent Encryptable
This package allows you to encrypt and decrypt model fields using the Hill Cipher algorithm in your Laravel application.
Table of Contents
- Features
- Matrix Key Support
- Language Support
- Installation
- 1. Install the package
- 2. Publish the configuration file
- 3. Configure the key matrix
- 4. Use the Hill Cipher service
- 5. Encrypt and decrypt model fields
- 6. Re-encrypt model data
- 7. Custom Validation Rules
- Unique Rule
- Exists Rule
- 8 . Blade Directives
Features
- Encrypts and decrypts model fields using the Hill Cipher algorithm.
- Supports re-encryption of model data with a new key matrix.
- Handles uppercase and lowercase letters, spaces, and numbers.
- encrypt and decrypt text using the Hill Cipher algorithm.
- Supports 2x2 and 3x3 key matrices.
Matrix Key Support
- [✅] 2x2 matrix
- [✅] 3x3 matrix
- [❌] 4x4 matrix
- [❌] 5x5 matrix
Language Support
- [✅] English
- [✅] Kurdish (Sorani)
- [✅] Arabic
Installation
1. Install the package
You can install the eloquent-encryptable
package via composer:
2. Publish the configuration file
you can publish the configuration file to change the key matrix for encryption and decryption, and assign models to re-encrypt by running the following command:
3. Configure the key matrix
in .env
file you can configure the key matrix for encryption and decryption, by adding the following lines:
now the key matrix should be a 2x2 matrix, and the previous key matrix is used to re-encrypt model data with a new key matrix.
4. Use for text encryption and decryption
You can use the EloquentEncryptAbleService
service to encrypt and decrypt text using the Hill Cipher algorithm.
output of the above code will be:
5. Encrypt and decrypt model fields
You can encrypt and decrypt model fields by using the EncryptAble
trait in your model class, and specify the fields that you want to encrypt in the $encryptAble
property.
now the name
and email
fields will be encrypted and decrypted automatically,
when you save and retrieve , like the following example:
the name
and email
fields will be encrypted in the database, and decrypted when you retrieve them.
6. Re-encrypt model data
You can re-encrypt model data with a new key matrix , but you should specify the previous key matrix in the .env
file.
and added models that you want to re-encrypt in the config/eloquent-encryptable.php
file:
then you can run the following command to re-encrypt model data:
This command will re-encrypt all model fields that are encrypted with the previous key matrix will be re-encrypted with the new key matrix.
7. Custom Validation Rules
Unique Rule
You can use the unique
validation rule with encrypted fields by using the EncryptAbleUniqueRule
rule.
and you can add 3rd parameter to expect a specific value:
Exists Rule
You can use the exists
validation rule with encrypted fields by using the EncryptAbleExistsRule
rule.
and you can add 3rd parameter to expect a specific value:
8. Blade Directives
You can use the @encrypt
and @decrypt
blade directives to encrypt and decrypt text in your blade views.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.