Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-laravel-encryptor

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-laravel-encryptor

node version Laravel encrypt

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
372
decreased by-40.76%
Maintainers
1
Weekly downloads
 
Created
Source

node-laravel-encryptor

NodeJS version of Laravel's 5.8 (and probably older versions) Encrypter Class Illuminate/Encryption/Encrypter.php

With this module you can create the encrypted payload for a cookie from Node Js and be read by Laravel.

Laravel Encrypter format:

Laravel only allows AES-128-CBC AES-256-CBC. If no algorithm is defined default is AES-256-CBC

{
  "iv":  "iv in base64",
  "value":  "encrypted data",
  "mac":  "Hash HMAC"
}

Install

$> npm i node-laravel-encryptor

Use

const {LaravelEncryptor} = require('node-laravel-encryptor');

let laravelEncryptor = new LaravelEncryptor({
    laravel_key: 'Laravel APP_KEY without base64:',
});

laravelEncryptor
    .encrypt('foo')
    .then(enc => console.log(enc));

laravelEncryptor
    .decrypt(enc)
    .then(dec => console.log(dec));

Options

Object {laravel_key, key_length}
  • laravel_key: APP_KEY without base64:
  • key_length: optional 32|64 for aes-[128]-cbc aes-[256]-cbc

if no key_length is given default is 64.

Methods

encrypt

arguments:

  • data: string
  • serialize: optional boolean, if data should be serialized before cipher

if no serialize option is given default is to serialize.

decrypt

arguments:

  • data: string
  • serialize: optional boolean, if data should be unserialized after decipher

if no serialize option is given default is to unserialize.

Tests

$> npm run test

To be able to run PHP test you must have installed:

  • PHP >= 7.1.3
  • OpenSSL PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • Ctype PHP Extension
  • JSON PHP Extension
  • BCMath PHP Extension

If not, test number 7 will fail.

$> npm run test

  node Laravel Encrypter
    ✓ should cipher and decipher
    ✓ should cipher and decipher with no key_length defined
    ✓ should cipher and decipher with no serialize nor unserialize
    ✓ should fail cipher not valid Laravel Key
    ✓ should fail cipher not valid algorithm
    ✓ should fail decipher not valid data
    ✓ should decipher data at Laravel correctly (51ms)


  7 passing (74ms)

Keywords

FAQs

Package last updated on 02 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc