fredbradley / google-storage-user-photos-encrypter
Customer Encrypter for user photos stored in Google Storage for Laravel applications.
Fund package maintenance!
Fred Bradley
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/fredbradley/google-storage-user-photos-encrypter
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
A custom encrypter for user photos stored in Google Cloud Storage, for the purpose of being able to encrypt the documents into Google Storage, but use them across multiple Laravel applications with the same encryption keys.
Installation
You can install the package via composer:
composer require fredbradley/google-storage-user-photos-encrypter
You can publish the config file with, but it's not necessary to:
php artisan vendor:publish --tag="google-storage-user-photos-encrypter-config"
You will need to add your USER_PHOTOS_ENCRYPTION_KEY and you may want to override the default cipher by adding these two lines to your .env file:
USER_PHOTOS_ENCRYPTION_KEY=base64:your-base64-encoded-key-here USER_PHOTOS_ENCRYPTION_CIPHER=AES-256-CBC
Usage
As a Facade:
// A check to see whether encrypter status is on. (Just add `USER_PHOTOS_ENCRYPTION_STATUS=on` to your .env to enable it) if (\FredBradley\GoogleStorageUserPhotosEncrypter\Facades\GoogleStorageUserPhotosEncrypter::active()) { // returns a bool } // Encrypt a value $encryptedString = \FredBradley\GoogleStorageUserPhotosEncrypter\Facades\GoogleStorageUserPhotosEncrypter::encrypt($string); // Decrypt a value $string = \FredBradley\GoogleStorageUserPhotosEncrypter\Facades\GoogleStorageUserPhotosEncrypter::decrypt($encryptedString);
Via Dependency Injection:
public function handle(\FredBradley\GoogleStorageUserPhotosEncrypter\GoogleStorageUserPhotosEncrypter $encrypter) { $string = "test string"; if ($encrypter::active()) { // Encrypt a value $encryptedString = $encrypter->encrypt($string); // Decrypt a value $string = $encrypter->decrypt($encryptedString); } return $string; }
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.