Skip to content

Commit 08f6dcd

Browse files
committed
docs: emphasize bidirectional encryption capabilities
- Add clear headline about bidirectional encryption - Include 'Why This Package?' section with use cases - Add real-world examples (API tokens, sessions, queue messages) - Update package.json description and keywords - Make Laravel↔Node.js encryption sharing the main selling point
1 parent 7c4cc28 commit 08f6dcd

File tree

2 files changed

+74
-18
lines changed

2 files changed

+74
-18
lines changed

README.md

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
44
[![CI](https://github.com/Rene-Roscher/laravel-node-encryption/actions/workflows/ci.yml/badge.svg)](https://github.com/Rene-Roscher/laravel-node-encryption/actions/workflows/ci.yml)
55
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66

7-
Laravel-compatible encryption/decryption for Node.js. Fully compatible with Laravel's built-in encryption.
7+
**🔐 Bidirectional encryption between Laravel (PHP) and Node.js**
8+
9+
Share encrypted data seamlessly between your Laravel backend and Node.js services. Encrypt in Laravel, decrypt in Node.js - or vice versa!
10+
11+
## Why This Package?
12+
13+
Perfect for microservices, APIs, and hybrid applications where you need to:
14+
- 🔄 **Share encrypted data** between Laravel and Node.js applications
15+
- 🔒 **Encrypt in Laravel**, decrypt in Node.js (and vice versa!)
16+
- 🚀 **Build microservices** that share encrypted tokens, sessions, or sensitive data
17+
- 🛡️ **Maintain security** across different technology stacks
818

919
## Features
1020

11-
- ✅ 100% Laravel compatible (8.x - 12.x)
12-
- ✅ Zero configuration (auto-detects `APP_KEY`)
13-
- ✅ AES-256-CBC encryption with HMAC-SHA256
14-
- ✅ No dependencies (optional `php-serialize` for complex objects)
21+
-**Fully bidirectional** - Encrypt/decrypt in both directions
22+
-**100% Laravel compatible** (8.x - 12.x)
23+
-**Zero configuration** - Auto-detects `APP_KEY`
24+
-**Production ready** - Battle-tested AES-256-CBC with HMAC-SHA256
25+
-**No dependencies** - Lightweight with optional `php-serialize`
1526

1627
## Installation
1728

@@ -48,29 +59,44 @@ const decrypted = encrypter.decrypt(laravelEncryptedString);
4859
- `encryptString(value)` - Encrypts string without serialization
4960
- `decryptString(payload)` - Decrypts string without deserialization
5061

51-
## Laravel Integration
62+
## Bidirectional Encryption Examples
5263

53-
### PHP (Laravel)
64+
### 🔄 Laravel → Node.js
5465
```php
66+
// Laravel: Encrypt data
5567
use Illuminate\Support\Facades\Crypt;
5668

57-
// Encrypt
58-
$encrypted = Crypt::encrypt('Hello from Laravel!');
69+
$userData = ['id' => 1, 'email' => '[email protected]'];
70+
$encrypted = Crypt::encrypt($userData);
5971

60-
// Decrypt from Node.js
61-
$decrypted = Crypt::decrypt($fromNodeJs);
72+
// Send $encrypted to Node.js service...
6273
```
6374

64-
### Node.js
6575
```javascript
76+
// Node.js: Decrypt data from Laravel
6677
const { LaravelEncrypter } = require('laravel-node-encryption');
6778
const encrypter = new LaravelEncrypter();
6879

69-
// Decrypt from Laravel
70-
const decrypted = encrypter.decrypt(fromLaravel);
80+
const userData = encrypter.decrypt(encryptedFromLaravel);
81+
console.log(userData); // { id: 1, email: '[email protected]' }
82+
```
83+
84+
### 🔄 Node.js → Laravel
85+
```javascript
86+
// Node.js: Encrypt data
87+
const encrypter = new LaravelEncrypter();
88+
const token = { userId: 1, expires: '2024-12-31' };
89+
const encrypted = encrypter.encrypt(token);
90+
91+
// Send encrypted to Laravel...
92+
```
93+
94+
```php
95+
// Laravel: Decrypt data from Node.js
96+
use Illuminate\Support\Facades\Crypt;
7197

72-
// Encrypt for Laravel
73-
const encrypted = encrypter.encrypt('Hello from Node.js!');
98+
$token = Crypt::decrypt($encryptedFromNode);
99+
// $token = ['userId' => 1, 'expires' => '2024-12-31']
74100
```
75101

76102
## Environment Setup
@@ -86,6 +112,32 @@ Or in `.env`:
86112
APP_KEY=base64:your-app-key-here
87113
```
88114

115+
## Real-World Use Cases
116+
117+
### 🔐 Secure API Tokens
118+
Share authentication tokens between Laravel API and Node.js microservices:
119+
```javascript
120+
// Node.js: Create encrypted token
121+
const token = encrypter.encrypt({ userId: 123, scope: 'api' });
122+
// Laravel can decrypt and validate this token
123+
```
124+
125+
### 🍪 Cross-Platform Sessions
126+
Share session data between Laravel web app and Node.js real-time service:
127+
```php
128+
// Laravel: Encrypt session
129+
$sessionData = Crypt::encrypt(session()->all());
130+
// Node.js WebSocket server can decrypt and use session
131+
```
132+
133+
### 📧 Queue Messages
134+
Encrypt sensitive job payloads between Laravel and Node.js workers:
135+
```javascript
136+
// Node.js: Encrypt job payload
137+
const job = encrypter.encrypt({ email: '[email protected]', action: 'welcome' });
138+
// Laravel queue worker decrypts and processes
139+
```
140+
89141
## Advanced Usage
90142

91143
### With explicit key

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "laravel-node-encryption",
33
"version": "1.0.0",
4-
"description": "Laravel-compatible encryption/decryption for Node.js - full compatibility with Laravel's encrypt() and decrypt()",
4+
"description": "Bidirectional encryption between Laravel (PHP) and Node.js - share encrypted data seamlessly across platforms",
55
"main": "src/index.js",
66
"scripts": {
77
"test": "jest",
@@ -14,14 +14,18 @@
1414
"laravel",
1515
"encryption",
1616
"decryption",
17+
"bidirectional",
18+
"cross-platform",
1719
"crypto",
1820
"aes",
1921
"aes-256-cbc",
2022
"php",
2123
"node",
2224
"nodejs",
2325
"laravel-encryption",
24-
"laravel-crypt"
26+
"laravel-crypt",
27+
"microservices",
28+
"api"
2529
],
2630
"author": "René Roscher <[email protected]>",
2731
"license": "MIT",

0 commit comments

Comments
 (0)