# encryptor-node

> Library for encrypting and decrypting messages using a secret key.

Latest version **1.0.0** (published 2020-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install encryptor-node
pnpm add encryptor-node
yarn add encryptor-node
bun add encryptor-node
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-09-04 |
| First published | 2020-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | cavillo |
| Maintainers | cavillo |
| Keywords | typescript, encryption |

## Links

- npm: https://www.npmjs.com/package/encryptor-node
- Repository: https://github.com/cavillo/encryptor-node
- Homepage: https://github.com/cavillo/encryptor-node#readme
- Issues: https://github.com/cavillo/encryptor-node/issues
- npm.io page: https://npm.io/package/encryptor-node

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-09-04
- 0.1.0 — 2020-02-01
- 0.0.2 — 2020-01-30
- 0.0.1 — 2020-01-30

## README

# Encryptor

[![Build Status](http://cloud.drone.io/api/badges/cavillo/encryptor-node/status.svg)](http://cloud.drone.io/cavillo/encryptor-node)

Library for encrypt and decrypt messages using a secret key.

## Installation

```sh
npm install --save encryptor-node
```

## Import methods

```ts
// As a whole
import * as Encryptor from 'encryptor-node';

// Each method
import { encrypt, decrypt } from 'encryptor-node';
```


## Encrypting and decrypting a message or object

```ts
import { encrypt, decrypt } from 'encryptor-node';

const secret = 's3cr3t!';
const payload = { message: 'This is an very important message' };

// Encrypting
const encrypted = encrypt(secret, payload);
console.log(encrypted); // e20f64009fe0daa88......

// Decrypting
const result = decrypt(secret, encrypted);
console.log(result); // { message: 'This is an very important message' }
```

## Extra Options

The `encrypt` function takes an additional optional `options` hash consisting of the following:

```ts
{
  /**
   * Optional - define the algorithm used for encryption
   * @default aes-256-cbc
   */
  algorithm?: string;

  /**
   * Optional - pass your own salt
   */
  salt?: string;

  /**
   * Optional - specify how long the generated salt string should be
   */
  saltLength?: number;

  /**
   * Optional - return encrypted data as a hex string, rather than a buffer. Defaults to true.
   */
  stringify?: boolean;
}
```

This is provided to allow the developer somewhat more control over the internals of the library.
The `decrypt` function takes an options hash with just the `algorithm` key.

The algorithm must be compatible with the built-in node crypto library.

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