Giter Site home page Giter Site logo

lcrypt's Introduction

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=

lcrypt's People

Contributors

lynxim avatar zhixun-hub avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.