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

1.0.1 2025-10-25 06:57 UTC

This package is auto-updated.

Last update: 2025-10-27 09:19:15 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.