# lcrypt

> Laravel crypt library

Latest version **2.0.2** (published 2022-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install lcrypt
pnpm add lcrypt
yarn add lcrypt
bun add lcrypt
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2022-11-30 |
| First published | 2017-11-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | lynxim |
| Maintainers | fskit |
| Keywords | simple aes, laravel aes, laravel crypt, laravel encrypt, laravel decrypt |

## Links

- npm: https://www.npmjs.com/package/lcrypt
- Repository: https://github.com/lynxim/lcrypt
- Homepage: https://lynx.im/lcrypt
- Issues: https://github.com/lynxim/lcrypt/issues
- npm.io page: https://npm.io/package/lcrypt

## Recent versions

- 2.0.2 (latest) — 2022-11-30
- 2.0.1 — 2022-11-30
- 2.0.0 — 2022-11-30
- 1.0.2 — 2017-11-04
- 1.0.1 — 2017-11-04
- 1.0.0 — 2017-11-04

## README

# lcrypt
Laravel encryption and decryption algorithm implemented in Nodejs.

## Install

```shell
npm install lcrypt
```

## Example

### NodeJS code

```javascript
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*

```text
eyJpdiI6ImRZdkxHRW1JZXdEVXJkdHB5dzloVUE9PSIsInZhbHVlIjoiOExpQTZYZFpkcG54VzZQVEtBbVdWQT09IiwibWFjIjoiODhmMTY2OTU2YWYyYzllNjVhNDNiOTUxZWU5ZTQ0OTU3ZjU2ZGYxOGEzOTI1YWJmOTJlNDQ5YjFjOTk0ZTlmZSJ9
hello world!
```

## For Laravel

Laravel .env file

```text
APP_KEY=base64:J92xtBr1tuLJV3mOFzMytJg4SDW0nirSAqMr7ZPGA4s=
```

### Laravel code

```php
<?php
use Illuminate\Support\Facades\Crypt;

echo Crypt::encryptString('some text.');
```

*Output*

```text
eyJpdiI6IldJZG9CYnhaYVhSN1JXVGVvL05zT3c9PSIsInZhbHVlIjoiSWwvVGdScFRZRm1KNTVnZnZEamg1Zz09IiwibWFjIjoiY2MzOTFhZmRhMTYxN2E4YWUzNDFhZTEwZGEzYTZlZjkwNzU3MDk0ZGIyODUzNjI1NjA5YjA5MDZkMjU3MWY4YSJ9
```

### NodeJS code

```javascript
import LCrypt from 'lcrypt';
const lcrypt = new LCrypt('J92xtBr1tuLJV3mOFzMytJg4SDW0nirSAqMr7ZPGA4s=');

console.log(lcrypt.decode('eyJpdiI6IldJZG9CYnhaYVhSN1JXVGVvL05zT3c9PSIsInZhbHVlIjoiSWwvVGdScFRZRm1KNTVnZnZEamg1Zz09IiwibWFjIjoiY2MzOTFhZmRhMTYxN2E4YWUzNDFhZTEwZGEzYTZlZjkwNzU3MDk0ZGIyODUzNjI1NjA5YjA5MDZkMjU3MWY4YSJ9'));
```

*Output*

```text
some text.
```

## Generate key

### NodeJS code

```javascript
import { randomBytes } from 'crypto';
console.log(randomBytes(32).toString('base64'));
```

*Output*

```text
ZvIfqyE25SXztlLf5iPrWTQt+6L18nVt3Gxh1XUJKYI=
```

---
_Source: https://npm.io/package/lcrypt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
