npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

laravel-node-encryption

v2.0.0

Published

Bidirectional encryption between Laravel (PHP) and Node.js - share encrypted data seamlessly across platforms

Readme

Laravel Node Encryption

npm version CI License: MIT

🔐 Bidirectional encryption between Laravel (PHP) and Node.js

Share encrypted data seamlessly between your Laravel backend and Node.js services. Encrypt in Laravel, decrypt in Node.js - or vice versa!

Why This Package?

Perfect for microservices, APIs, and hybrid applications where you need to:

  • 🔄 Share encrypted data between Laravel and Node.js applications
  • 🔒 Encrypt in Laravel, decrypt in Node.js (and vice versa!)
  • 🚀 Build microservices that share encrypted tokens, sessions, or sensitive data
  • 🛡️ Maintain security across different technology stacks

Features

  • Fully bidirectional - Encrypt/decrypt in both directions
  • 100% Laravel compatible (8.x - 12.x)
  • Zero configuration - Auto-detects APP_KEY
  • Production ready - Battle-tested AES-256-CBC with HMAC-SHA256
  • No dependencies - Lightweight with optional php-serialize

Installation

npm install laravel-node-encryption

Quick Start

const { LaravelEncrypter } = require('laravel-node-encryption');

// Automatically uses process.env.APP_KEY
const encrypter = new LaravelEncrypter();

// Encrypt data
const encrypted = encrypter.encrypt('Hello Laravel!');

// Decrypt data from Laravel
const decrypted = encrypter.decrypt(laravelEncryptedString);

API

new LaravelEncrypter(key?, cipher?)

  • key - Encryption key (defaults to process.env.APP_KEY)
  • cipher - Cipher method (default: 'aes-256-cbc')

Methods

  • encrypt(value) - Encrypts any value
  • decrypt(payload) - Decrypts Laravel-encrypted payload
  • encryptString(value) - Encrypts string without serialization
  • decryptString(payload) - Decrypts string without deserialization

Bidirectional Encryption Examples

🔄 Laravel → Node.js

// Laravel: Encrypt data
use Illuminate\Support\Facades\Crypt;

$userData = ['id' => 1, 'email' => '[email protected]'];
$encrypted = Crypt::encrypt($userData);

// Send $encrypted to Node.js service...
// Node.js: Decrypt data from Laravel
const { LaravelEncrypter } = require('laravel-node-encryption');
const encrypter = new LaravelEncrypter();

const userData = encrypter.decrypt(encryptedFromLaravel);
console.log(userData); // { id: 1, email: '[email protected]' }

🔄 Node.js → Laravel

// Node.js: Encrypt data
const encrypter = new LaravelEncrypter();
const token = { userId: 1, expires: '2024-12-31' };
const encrypted = encrypter.encrypt(token);

// Send encrypted to Laravel...
// Laravel: Decrypt data from Node.js
use Illuminate\Support\Facades\Crypt;

$token = Crypt::decrypt($encryptedFromNode);
// $token = ['userId' => 1, 'expires' => '2024-12-31']

Environment Setup

Set your Laravel APP_KEY in environment:

APP_KEY='base64:your-app-key-here' node app.js

Or in .env:

APP_KEY=base64:your-app-key-here

Real-World Use Cases

🔐 Secure API Tokens

Share authentication tokens between Laravel API and Node.js microservices:

// Node.js: Create encrypted token
const token = encrypter.encrypt({ userId: 123, scope: 'api' });
// Laravel can decrypt and validate this token

🍪 Cross-Platform Sessions

Share session data between Laravel web app and Node.js real-time service:

// Laravel: Encrypt session
$sessionData = Crypt::encrypt(session()->all());
// Node.js WebSocket server can decrypt and use session

📧 Queue Messages

Encrypt sensitive job payloads between Laravel and Node.js workers:

// Node.js: Encrypt job payload
const job = encrypter.encrypt({ email: '[email protected]', action: 'welcome' });
// Laravel queue worker decrypts and processes

Advanced Usage

With explicit key

const encrypter = new LaravelEncrypter('base64:your-key-here');

Express.js middleware

app.post('/decrypt', (req, res) => {
    try {
        const decrypted = encrypter.decrypt(req.body.encrypted);
        res.json({ data: decrypted });
    } catch (error) {
        res.status(400).json({ error: 'Invalid encrypted data' });
    }
});

Compatibility

| Laravel | Node.js | PHP | Status | |---------|---------|--------|--------| | 12.x | 18+ | 8.3+ | ✅ | | 11.x | 18+ | 8.2+ | ✅ | | 10.x | 16+ | 8.1+ | ✅ | | 9.x | 14+ | 8.0+ | ✅ | | 8.x | 14+ | 7.3+ | ✅ |

License

MIT © René Roscher