Skip to content

lynxim/lcrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lcrypt

Laravel encryption and decryption algorithm implemented in Nodejs.

Install

npm install lcrypt

Example

NodeJS code

import LCrypt from 'lcrypt';

// LCrypt expects a 16bits, 24bits or 32bits base64 string to be used as key.
const lcrypt = new LCrypt('J92xtBr1tuLJV3mOFzMytJg4SDW0nirSAqMr7ZPGA4s=');

let cipherText = lcrypt.encode('hello world!');

console.log(cipherText);
console.log(lcrypt.decode(cipherText));

Output

eyJpdiI6ImRZdkxHRW1JZXdEVXJkdHB5dzloVUE9PSIsInZhbHVlIjoiOExpQTZYZFpkcG54VzZQVEtBbVdWQT09IiwibWFjIjoiODhmMTY2OTU2YWYyYzllNjVhNDNiOTUxZWU5ZTQ0OTU3ZjU2ZGYxOGEzOTI1YWJmOTJlNDQ5YjFjOTk0ZTlmZSJ9
hello world!

For Laravel

Laravel .env file

APP_KEY=base64:J92xtBr1tuLJV3mOFzMytJg4SDW0nirSAqMr7ZPGA4s=

Laravel code

<?php
use Illuminate\Support\Facades\Crypt;

echo Crypt::encryptString('some text.');

Output

eyJpdiI6IldJZG9CYnhaYVhSN1JXVGVvL05zT3c9PSIsInZhbHVlIjoiSWwvVGdScFRZRm1KNTVnZnZEamg1Zz09IiwibWFjIjoiY2MzOTFhZmRhMTYxN2E4YWUzNDFhZTEwZGEzYTZlZjkwNzU3MDk0ZGIyODUzNjI1NjA5YjA5MDZkMjU3MWY4YSJ9

NodeJS code

import LCrypt from 'lcrypt';
const lcrypt = new LCrypt('J92xtBr1tuLJV3mOFzMytJg4SDW0nirSAqMr7ZPGA4s=');

console.log(lcrypt.decode('eyJpdiI6IldJZG9CYnhaYVhSN1JXVGVvL05zT3c9PSIsInZhbHVlIjoiSWwvVGdScFRZRm1KNTVnZnZEamg1Zz09IiwibWFjIjoiY2MzOTFhZmRhMTYxN2E4YWUzNDFhZTEwZGEzYTZlZjkwNzU3MDk0ZGIyODUzNjI1NjA5YjA5MDZkMjU3MWY4YSJ9'));

Output

some text.

Generate key

NodeJS code

import { randomBytes } from 'crypto';
console.log(randomBytes(32).toString('base64'));

Output

ZvIfqyE25SXztlLf5iPrWTQt+6L18nVt3Gxh1XUJKYI=

About

Laravel crypt library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published