PHPackages                             tourze/json-rpc-encrypt-bundle - 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. [Security](/categories/security)
4. /
5. tourze/json-rpc-encrypt-bundle

ActiveSymfony-bundle[Security](/categories/security)

tourze/json-rpc-encrypt-bundle
==============================

JsonRPC加解密实现

2.0.0(4mo ago)02601MITPHPCI passing

Since Apr 13Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/json-rpc-encrypt-bundle)[ Packagist](https://packagist.org/packages/tourze/json-rpc-encrypt-bundle)[ RSS](/packages/tourze-json-rpc-encrypt-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (28)Versions (10)Used By (1)

JsonRPCEncryptBundle
====================

[](#jsonrpcencryptbundle)

[English](README.md) | [中文](README.zh-CN.md)

[![PHP Version](https://camo.githubusercontent.com/c12661d44f71ff6afaa31bff49b6a05e8744c78ee8cfefdfaf80b601c537d45b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746f75727a652f6a736f6e2d7270632d656e63727970742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/json-rpc-encrypt-bundle)[![Latest Version](https://camo.githubusercontent.com/75bd1f3a750af1abd05a75e38be2f6167336f7f741b2dd4e17d1beb6515cf5c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f6a736f6e2d7270632d656e63727970742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/json-rpc-encrypt-bundle)[![License](https://camo.githubusercontent.com/9e67adaee0d9d2c441eb5b256d1d2ed8f55af7964a04c6507a750fba20fd2ece/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f75727a652f6a736f6e2d7270632d656e63727970742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/json-rpc-encrypt-bundle)[![Build Status](https://camo.githubusercontent.com/1837ae352efddfd84c1f3aeebdcf46028ae4e8a881cbe8b71c17e60012e83a3d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f75727a652f6a736f6e2d7270632d656e63727970742d62756e646c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/tourze/json-rpc-encrypt-bundle)[![Coverage Status](https://camo.githubusercontent.com/fd1886ed605604ce6854e30c6f72f73d3f20723979aa6ba89864d7a12391d27d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f6a736f6e2d7270632d656e63727970742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/tourze/json-rpc-encrypt-bundle)[![Total Downloads](https://camo.githubusercontent.com/08dd0310e6f824032009478e1d08d8379f29fa8f3901009e2e380ec459b4e952/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f6a736f6e2d7270632d656e63727970742d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/json-rpc-encrypt-bundle)

A Symfony bundle for encrypting and decrypting JsonRPC requests and responses, ensuring sensitive data security during transmission.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Quick Start](#quick-start)
- [Advanced Usage](#advanced-usage)
- [Security](#security)
- [Dependencies](#dependencies)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- AES-256-CBC symmetric encryption for data transmission
- Automatic decryption for incoming requests, automatic encryption for outgoing responses
- Multi-AppID and multi-secret management
- Compatible with standard JsonRPC workflow
- Flexible event subscriber mechanism
- Comprehensive test coverage

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

[](#installation)

**Requirements:**

- PHP 8.1+
- Symfony 6.4+

**Install via Composer:**

```
composer require tourze/json-rpc-encrypt-bundle
```

Dependencies
------------

[](#dependencies)

This bundle requires the following packages:

- `tourze/json-rpc-core` - Core JsonRPC functionality
- `tourze/json-rpc-endpoint-bundle` - JsonRPC endpoint handling
- `symfony/framework-bundle` - Symfony framework
- `doctrine/orm` - Database ORM support

Configuration
-------------

[](#configuration)

1. **Register the bundle** in your Symfony application:

```
// config/bundles.php
return [
    // ...
    Tourze\JsonRPCEncryptBundle\JsonRPCEncryptBundle::class => ['all' => true],
];
```

3. **Service Configuration** (optional):

```
# config/services.yaml
services:
    Tourze\JsonRPCEncryptBundle\Service\Encryptor:
        # Custom configuration if needed
```

Quick Start
-----------

[](#quick-start)

**Client-side setup:**

1. Add `Encrypt-AppID` header to your JsonRPC requests
2. Encrypt the payload using AES-256-CBC with your appSecret

```
curl -X POST http://your-server/jsonrpc \
  -H "Content-Type: application/json" \
  -H "Encrypt-AppID: your-app-id" \
  -d ""
```

**Server-side behavior:**

- Automatically decrypts incoming requests with `Encrypt-AppID` header
- Automatically encrypts outgoing responses for encrypted requests
- Maintains standard JsonRPC error handling

Advanced Usage
--------------

[](#advanced-usage)

### Custom Encryption Logic

[](#custom-encryption-logic)

Extend the `Encryptor` service for custom encryption implementations:

```
use Tourze\JsonRPCEncryptBundle\Service\Encryptor;

class CustomEncryptor extends Encryptor
{
    public function encryptData(string $rawString, string $signSecret, string $signKey): string
    {
        // Your custom encryption logic
        return parent::encryptData($rawString, $signSecret, $signKey);
    }
}
```

### Event Subscribers

[](#event-subscribers)

The bundle provides `EncryptSubscriber` that handles:

- `RequestStartEvent` - Decrypts incoming requests
- `ResponseSendingEvent` - Encrypts outgoing responses

### Error Handling

[](#error-handling)

The bundle throws specific exceptions:

- `EncryptAppIdMissingException` - When Encrypt-AppID header is missing
- `EncryptAppIdNotFoundException` - When AppID is not found or invalid

Security
--------

[](#security)

**Encryption Details:**

- Algorithm: AES-256-CBC
- Key derivation: SHA-256 hash of appSecret
- IV generation: MD5 hash of appId (16 bytes)
- Data encoding: Base64

**Security Considerations:**

- Always use HTTPS in production
- Rotate appSecret regularly
- Validate AppID permissions
- Monitor encryption/decryption failures
- Keep encryption keys secure

**Important Security Notes:**

- This bundle provides data encryption but does not replace proper authentication
- Ensure proper key management practices
- Consider implementing rate limiting for encryption endpoints

Documentation
-------------

[](#documentation)

- See `DataEncryption.puml` for the encryption process flowchart
- Check inline PHPDoc comments for detailed API documentation
- Review test cases for usage examples

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Follow PSR coding standards
4. Ensure new features are fully tested
5. Submit a pull request

**Development setup:**

```
git clone https://github.com/tourze/json-rpc-encrypt-bundle.git
cd json-rpc-encrypt-bundle
composer install
vendor/bin/phpunit
```

License
-------

[](#license)

MIT License - see [LICENSE](LICENSE) file for details.

Copyright © Tourze Team

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for release notes and version history.

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance79

Regular maintenance activity

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

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

Recently: every ~56 days

Total

9

Last Release

141d ago

Major Versions

0.1.2 → 1.0.02025-11-05

1.0.1 → 2.0.02025-12-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-json-rpc-encrypt-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-json-rpc-encrypt-bundle/health.svg)](https://phpackages.com/packages/tourze-json-rpc-encrypt-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M309](/packages/easycorp-easyadmin-bundle)

PHPackages © 2026

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