开源软件名称(OpenSource Name):austinheap/laravel-database-encryption开源软件地址(OpenSource Url):https://github.com/austinheap/laravel-database-encryption开源编程语言(OpenSource Language):PHP 97.9%开源软件介绍(OpenSource Introduction):Laravel 5.5+ Database Encryption PackageA package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.The purpose of this project is to create a set-it-and-forget-it package that can be installed without much effort to encrypt and decrypt Eloquent model attributes stored in your database tables, transparently. It is therefore highly opinionated but built for configuration. When enabled, it automagically begins encrypting data as it is stored in the model attributes and decrypting data as it is recalled from the model attributes. All data that is encrypted is prefixed with a header so that encrypted data can be easily identified, encryption keys rotated, and (optionally) versioning of the encrypted data format itself. This supports columns that store either encrypted or non-encrypted data to make migration easier. Data can be read from columns correctly regardless of whether it is encrypted or not but will be automatically encrypted when it is saved back into those columns. Standard Laravel Eloquent features like attribute casting will continue to work as normal, even if the underlying values stored in the database are encrypted by this package. There is documentation for Table of Contents
Requirements
Status
SchemasEncrypted values are usually longer than plain text values, sometimes much longer. You may find that the column widths in your database tables need to be altered to store the encrypted values generated by this package. If you are encrypting long strings such as JSON blobs then the encrypted values may
be longer than a The FAQ contains migration instructions if you are moving from elocryptfive. InstallationStep 1: ComposerVia Composer command line: $ composer require austinheap/laravel-database-encryption Or add the package to your {
"require": {
"austinheap/laravel-database-encryption": "^0.2"
}
} Step 2: Enable the package (Optional)This package implements Laravel auto-discovery feature. After you install it the package provider and facade are added automatically. If you would like to declare the provider and/or alias explicitly, you may do so by first
adding the service provider to your 'providers' => [
//
AustinHeap\Database\Encryption\EncryptionServiceProvider::class,
]; And then add the alias to your 'aliases' => [
//
'DatabaseEncryption' => AustinHeap\Database\EncryptionFacade::class,
]; Step 3: Configure the packagePublish the package config file: $ php artisan vendor:publish --provider="AustinHeap\Database\Encryption\EncryptionServiceProvider" You may now enable automagic encryption and decryption of Eloquent models by editing the
return [
'enabled' => env('DB_ENCRYPTION_ENABLED', true),
]; Or simply setting the the DB_ENCRYPTION_ENABLED=true UsageUse the For example: use AustinHeap\Database\Encryption\Traits\HasEncryptedAttributes;
class User extends Eloquent {
use HasEncryptedAttributes;
/**
* The attributes that should be encrypted on save.
*
* @var array
*/
protected $encrypted = [
'address_line_1', 'first_name', 'last_name', 'postcode'
];
} You can combine For example: use AustinHeap\Database\Encryption\Traits\HasEncryptedAttributes;
class User extends Eloquent {
use HasEncryptedAttributes;
protected $casts = ['extended_data' => 'array'];
protected $encrypted = ['extended_data'];
} By including the Keys and IVsThe key and encryption algorithm used is the default Laravel 'key' => env('APP_KEY', 'SomeRandomString'),
'cipher' => 'AES-256-CBC', If you're using The IV for encryption is randomly generated and cannot be set. Unit TestsThis package has aggressive unit tests built with the wonderful orchestral/testbench package which is built on top of PHPUnit. A MySQL server required for execution of unit tests. There are code coverage reports for OverridesThe following Laravel 5.5 methods from Eloquent are affected by this trait.
FAQCan I manually encrypt or decrypt arbitrary data?Yes! You can manually encrypt or decrypt data using the $user = new User();
$encryptedEmail = $user->encryptedAttribute(Input::get('email')); Can I search encrypted data?No! You will not be able to search on attributes which are encrypted by this package because...it is encrypted. Comparing encrypted values would require a fixed IV, which introduces security issues. If you need to search on data then either:
You could store both a hashed and an encrypted value, using the hashed value for searching and retrieve the encrypted value as needed.
Can I encrypt all my |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论