PHPackages                             dev-phoenix/psr7-decorator - 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. dev-phoenix/psr7-decorator

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

dev-phoenix/psr7-decorator
==========================

psr7 cipher decorator

v3.1.1(10mo ago)01PHPPHP &gt;=8.2

Since Jul 18Pushed 10mo agoCompare

[ Source](https://github.com/dev-phoenix/psr-7-ciphered-decorator)[ Packagist](https://packagist.org/packages/dev-phoenix/psr7-decorator)[ RSS](/packages/dev-phoenix-psr7-decorator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

PSR-7 Encription / Decription decorator
=======================================

[](#psr-7-encription--decription-decorator)

Required PHP v8.x
-----------------

[](#required-php-v8x)

Checked on PHP v8.2

Install:
--------

[](#install)

```
composer require dev-phoenix/psr7-decorator
```

Exemples:
---------

[](#exemples)

```
require_once 'vendor/autoload.php';

use GuzzleHttp\Psr7\Stream;
use DevPhoenix\Psr7Decorator\StreamDecoratorDecode;
use DevPhoenix\Psr7Decorator\StreamDecoratorEncode;
use DevPhoenix\Psr7Decorator\H;

$out_dir_name = '/results'; // needs already be created
$parent_dir = dirname(__FILE__);
$out_dir = $parent_dir . $out_dir_name;

$mediaKey = 'secret key';

$test_data = 'abcd efgh ijkl mnop';
file_put_contents($out_dir.'/orig_data.txt', $test_data);

// Encripting
$inStream = new Stream(fopen($out_dir.'/orig_data.txt', 'r')); // PSR-7 stream
$decoder = new StreamDecoratorEncode($inStream, $mediaKey); // add decorator
$encriptedresult = $decoder -> getContents();

H::pre($encriptedresult, 'encripted'); // output

// save intermediate data dump
file_put_contents($out_dir.'/enc_data.txt', $encriptedresult);

// Decription
$inStream = new Stream(fopen($out_dir.'/enc_data.txt', 'r')); // PSR-7 stream
$decoder = new StreamDecoratorDecode($inStream, $mediaKey); // add decorator
$originalresult = $decoder -> getContents();

H::pre($originalresult, 'decoded'); // output
```

Out:
[![out](./imgs/img_1.png)](./imgs/img_1.png)

Exemples with exemple files:
----------------------------

[](#exemples-with-exemple-files)

```
require_once 'vendor/autoload.php';

use DevPhoenix\Psr7Decorator\DecoderTester;
use DevPhoenix\Psr7Decorator\H;

// prepare sources dir parh
$src_dir_name = '/samples';
$out_dir_name = '/results';
$parent_dir = dirname(__FILE__);
$src_dir = $parent_dir . $src_dir_name;
$out_dir = $parent_dir . $out_dir_name;

// allowed file names which means file media type
$fname_D = 'DOCUMENT';
$fname_A = 'AUDIO';
$fname_I = 'IMAGE';
$fname_V = 'VIDEO';

// Cipher test class specially for files
$decoder = new DecoderTester($src_dir, $out_dir);
H::pre('DecoderTester created.');
$size = $decoder -> processDecription($fname_I, $fname_I.'_4', $src_dir, $out_dir);
H::pre('DecoderTester decription complited.');
$size = $decoder -> processEncription($fname_I, $fname_I.'_4', $src_dir, $out_dir);
H::pre('DecoderTester encription complited.');

// compare encripted files, origin encripted and generated encripted
$in_enc_fname = $src_dir . '/' . $fname_I.'' . '.encrypted';
$out_enc_fname = $out_dir . '/' . $fname_I.'_4' . '.encrypted';

$hashe_1 = hash_file('sha256', $in_enc_fname);
$hashe_2 = hash_file('sha256', $out_enc_fname);

$mess_1 = sprintf('%s ', $fname_I.'' . '.encrypted hash');
$mess_2 = sprintf('%s ', $fname_I.'_4' . '.encrypted hash');
$mess_3 = sprintf('Compare %s and %s', $fname_I.'' . '.encrypted', $fname_I.'_4' . '.encrypted');
H::pre($hashe_1, $mess_1);
H::pre($hashe_2, $mess_2);
H::pre(($hashe_1 == $hashe_2)?'equal':'not equal',$mess_3);
```

Out:
[![out](./imgs/img_2.png)](./imgs/img_2.png)

Exemples with simple string:
----------------------------

[](#exemples-with-simple-string)

Only cipher without psr7

```
require_once 'vendor/autoload.php';

use DevPhoenix\Psr7Decorator\Decoder;
use DevPhoenix\Psr7Decorator\H;

$mediaKey = 'secret key';
$data = 'secret data';
$data_ = 'secret data';

$out_dir_name = '/results';
$parent_dir = dirname(__FILE__);
$out_dir = $parent_dir . $out_dir_name;

$decoder = new Decoder();
H::pre($data, sprintf('incoming data len( %s )',H::strSize(strlen($data))));
$data = $decoder -> processEncript($mediaKey, $data);
H::pre($data, sprintf('encripted data len( %s )',H::strSize(strlen($data))));

file_put_contents($out_dir.'/enc_f_data.txt', $data); // save cipher data
$data_ = file_get_contents($out_dir.'/enc_f_data.txt'); // load cipher data

$data = $decoder -> processDecript($mediaKey, $data_);
H::pre($data, sprintf('decripted data len( %s )',H::strSize(strlen($data))));

H::pre($data_, sprintf('encripted loaded data len( %s )',H::strSize(strlen($data_))));
$data = $decoder -> processDecript($mediaKey, $data_);
H::pre($data, sprintf('decripted loaded data len( %s )',H::strSize(strlen($data))));
```

Out:
[![out](./imgs/img_3.png)](./imgs/img_3.png)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance55

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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 ~0 days

Total

3

Last Release

304d ago

Major Versions

v1.0.0 → v3.1.02025-07-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c1133cbb3eeae6bc7836bd6b26bbe545dc5af19e811f10cb572f4f830a21e61?d=identicon)[dev-phoenix](/maintainers/dev-phoenix)

---

Top Contributors

[![dev-phoenix](https://avatars.githubusercontent.com/u/43040280?v=4)](https://github.com/dev-phoenix "dev-phoenix (10 commits)")

### Embed Badge

![Health badge](/badges/dev-phoenix-psr7-decorator/health.svg)

```
[![Health](https://phpackages.com/badges/dev-phoenix-psr7-decorator/health.svg)](https://phpackages.com/packages/dev-phoenix-psr7-decorator)
```

###  Alternatives

[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[php-tuf/php-tuf

PHP implementation of The Update Framework (TUF)

456.5k1](/packages/php-tuf-php-tuf)[millerphp/laravel-browserless

This is my package laravel-browserless

1212.0k](/packages/millerphp-laravel-browserless)

PHPackages © 2026

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