Download the PHP package redsd/aesencrypt without Composer
On this page you can find all versions of the php package redsd/aesencrypt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package aesencrypt
- Installation
- Configure Provider
- Updating your Eloquent Models
- Creating tables to support encrypt columns
- Set encryption key in .env file
- Encrypt existing data
- Decrypt your data in MySQL
Laravel MySql AES Encrypt/Decrypt
Based on https://github.com/devmaster10/mysql-aes-encrypt
Improvements:
- Added improved security by using an unique IV for each encrypted field.
- Added support for multiple encryption methods including: aes-256-cbc
- Added use of MySQL session variables to prevent the encryption key from being outputted when an sql error occures.
- Added laravel 9 support
Laravel Database Encryption in mysql side, use native mysql function AES_DECRYPT and AES_ENCRYPT
Auto encrypt and decrypt signed fields/columns in your Model
Can use all functions of Eloquent/Model
You can perform the operations "=>, <',' between ',' LIKE ' in encrypted columns
1.Install the package via Composer:
2.Configure provider
You'll need to add to add a service provider if you are using Laravel 5.4 or lower or if the encryption is not working, add to following in config/app.php:
Updating Your Eloquent Models
Your models that have encrypted columns, should extend from ModelEncrypt:
Creating tables to support encrypt columns
It adds new features to Schema which you can use in your migrations:
Set encryption settings in .env file
See https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_block_encryption_mode for all available encryption methods.
To publish the config file and view run the following command
Encrypt existing data
In order to use this package with existing data, you must first encrypt all existing columns you want to use.
Note: If the database is allready encrypted, make sure to decrypt it before executing the folowing query.
Always make a back-up before making changes to your data
The easiest and more secure way to use this, is to use this MySQL function when updating your records:
After adding the MySQL function, update your records like so:
The folowing code will ensure the only data that isn't encrypted yet will be encrypted, in case you need to run the query multiple times.
If you cannot create MySQL functions you can perform the following but this will use the same IV for every record which is less secure.
The folowing code will ensure the only data that isn't encrypted yet will be encrypted, in case you need to run the query multiple times.
Decrypt your data in MySQL
If you want to decrypt your data using mysql query, you can add this function to your mysql database:
Now when you want to decrypt your mysql you can do so like this:
Or if you cannot or do not want to use a MySQL function you can use the following query
All versions of aesencrypt with dependencies
illuminate/config Version ^9.0
illuminate/database Version ^9.0
illuminate/support Version ^9.0