PHPackages                             hxm/media-encrypt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hxm/media-encrypt

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hxm/media-encrypt
=================

Media Encrypt

v1.0.7(2y ago)734proprietaryPHPPHP ^7.0|^8.0

Since Oct 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/hoanxuanmai/media-encrypt)[ Packagist](https://packagist.org/packages/hxm/media-encrypt)[ RSS](/packages/hxm-media-encrypt/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (9)Used By (0)

 [![Laravel 7.x/8.x/9.x/10.x](https://camo.githubusercontent.com/af0f1686ad34ade25b2cf4c10bde1072b196265a2c984a83ab7279eada41e9fb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d372e782f382e782f392e782f31302e782d7265642e737667)](https://laravel.com) [![Donate](https://camo.githubusercontent.com/a5409ebe038bee6ef1c6241ee8ce4680f7cdde143f8d3cab05ab82ac6e321ee7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d253343332d726564)](https://www.paypal.me/MaiXuanHoan)

Media Encrypt
=============

[](#media-encrypt)

**Media Encrypt** is a powerful PHP package designed for encrypting sensitive data before storing it in a database. This package provides a secure solution to protect your critical data from unauthorized access.

Installation
------------

[](#installation)

You can install this package via Composer with the following command:

```
  composer require hxm/media-encrypt
```

After successfully installing the **Media Encrypt** package, you need to perform some configuration steps to start using it in your project.

1. **Publish Config File**: You can publish the configuration file to customize the settings according to your specific requirements by running the following command: ```
    php artisan vendor:publish --provider="HXM\MediaEncrypt\MediaEncryptServiceProvider" --tag="media-encrypt-config"
    ```

    The configuration file will be published to `config/media-encrypt.php`.
2. **Migrate Database**: After the configuration is done, you need to run the migrate command to create the necessary tables in the database: ```
    php artisan migrate
    ```

Usage
-----

[](#usage)

To use the **Media Encrypt** package in your Laravel project, you can refer to the following example code:

1. **Inherit** `CanMediaEncryptInterface` in your Model, then use the `HasMediaEncrypt` trait in it.

    ```
    use Illuminate\Database\Eloquent\Model;
    use HXM\MediaEncrypt\Contracts\CanMediaEncryptInterface;
    use HXM\MediaEncrypt\Traits\HasMediaEncrypt;

    class OnlineRequest extends Model implements CanMediaEncryptInterface
    {
        use HasMediaEncrypt;
        #...
    }
    ```
2. **Define**: To define the `field` you want to use with the `Media Encrypt` data, you just need to add it to the `$casts` attribute in the model itself. Here is the complete code for your `Model`:

    ```
    use Illuminate\Database\Eloquent\Model;
    use HXM\MediaEncrypt\Contracts\CanMediaEncryptInterface;
    use HXM\MediaEncrypt\Traits\HasMediaEncrypt;
    use HXM\MediaEncrypt\Casts\MediaEncryptCast;
    use HXM\MediaEncrypt\Casts\MultiMediaEncryptCast;

    class DemoModel extends Model implements CanMediaEncryptInterface
    {
    use HasMediaEncrypt;

        protected $appends = ['baseData', 'media', 'media_multi'];

        protected $casts = [
            #...
            'baseData' => MediaEncryptCast::class,
            'media' => MediaEncryptCast::class,
            'media_multi' => MultiMediaEncryptCast::class,
        ];
        #...
    }
    ```

    - The `MediaEncryptCast` will encode the data into one block.
    - the `MultiMediaEncryptCast` will understand that your data is stored in the form of an `Array`, with each sub-element being encrypted separately. If your data is a `Media file` data array, you must use this cast
3. **Encrypt and store data**:

    ```
    $model = Demo::first();

    $model->baseData = [
        'row' => 1,
        'column' => 2,
    ];

    $model->media = request()->file('file');

    $model->media_multi = [
        'file1' => request()->file('file1'),
        'file2' => request()->get('file2'),
    ];
    $model->save();
    ```
4. **Access the encrypted data**:

    ```
    $model = Demo::first();

    dump($model->baseData);
    #@return: instance  HXM\MediaEncrypt\Models\MediaEncrypt

    dump($model->baseData->toAray());
    #@return: array:2 [
    #   'row' => 1
    #   'column' => 2
    #   ]

    dump($model->media->toUrl());
    #@return: https://baseUrl/encrypt_media/4f03a151-14a9-4234...
    dump($model->media_multi->decrypt());
    #@return: array:2 [
    #   'file1' => https://baseUrl/encrypt_media/4f03a151-14a9-4234...
    #   'file2' => data:image/jpg;base64,/9j/4QAYRXh.........
    #   ]
    ```

    - When accessing the property, you will receive an instance of `HXM\MediaEncrypt\Models\MediaEncrypt`
    - The `Media file` data will be encrypted and stored in the database, so after decryption, we will return it to the base64 code of the content.
    - Raw data such as text, array will be encrypted and returned unchanged.
5. **Append**: If you want to `append` the decrypted data, simply add the fields you want to the `$appends` attribute of the `Model`:

    ```
    protected $appends = ['baseData', 'media', 'media_multi'];
    ```

Contribution
------------

[](#contribution)

If you encounter any issues or have any suggestions for improvements, please open an issue on GitHub [here](https://github.com/hoanxuanmai/media-encrypt/issues). We welcome contributions from the community.

License
-------

[](#license)

The **Media Encrypt** package is distributed under the [MIT License](https://opensource.org/licenses/MIT). Please refer to the LICENSE file for detailed information about this license.

Contact
-------

[](#contact)

If you have any questions, please feel free to contact us via email at [](mailto:hoanxuanmai@gmail.com). We will try to respond as soon as possible.

[HoanXuanMai](https://github.com/hoanxuanmai)
=============================================

[](#hoanxuanmai)

We hope that the **Media Encrypt** package will help you secure your important data effectively. Thank you for using our package!

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

8

Last Release

885d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/253837bebf61531c6bb369dad0dd5e54136bd557b6583f058301ad837d5fa8dc?d=identicon)[hoanxuanmai](/maintainers/hoanxuanmai)

---

Top Contributors

[![hoanxuanmai](https://avatars.githubusercontent.com/u/47692574?v=4)](https://github.com/hoanxuanmai "hoanxuanmai (12 commits)")

### Embed Badge

![Health badge](/badges/hxm-media-encrypt/health.svg)

```
[![Health](https://phpackages.com/badges/hxm-media-encrypt/health.svg)](https://phpackages.com/packages/hxm-media-encrypt)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
