# encr

> Simple promise based encryption wrapper for Node.js and CLI based on crypto module

Latest version **1.0.10** (published 2022-08-10) · Apache-2.0 license · 0 weekly downloads

## Install

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

Provides the command `encr`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2022-08-10 |
| First published | 2020-01-23 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Amrayn Web Services |
| Maintainers | firewebkit-devs |

## Links

- npm: https://www.npmjs.com/package/encr
- Repository: https://github.com/amrayn/encr
- Homepage: https://github.com/amrayn/encr#readme
- Issues: https://github.com/amrayn/encr/issues
- npm.io page: https://npm.io/package/encr

## Dependencies (2)

- [inquirer](https://npm.io/package/inquirer.md) ^7.0.3
- [minimist](https://npm.io/package/minimist.md) ^1.2.0

## Recent versions

- 1.0.10 (latest) — 2022-08-10
- 1.0.9 — 2022-08-10
- 1.0.8 — 2020-04-08
- 1.0.7 — 2020-04-08
- 1.0.6 — 2020-01-23
- 1.0.5 — 2020-01-23
- 1.0.4 — 2020-01-23
- 1.0.3 — 2020-01-23
- 1.0.2 — 2020-01-23
- 1.0.1 — 2020-01-23
- 1.0.0 — 2020-01-23

## README

# encr
Simple promise based encryption wrapper for Node.js and CLI based on crypto module

<p align="center">
    •   •   •
</p>

<p align="center">
  <a aria-label="NPM version" href="https://www.npmjs.com/package/encr">
    <img alt="" src="https://img.shields.io/npm/v/encr.svg?style=for-the-badge&labelColor=000000">
  </a>
  <a aria-label="License" href="https://github.com/amrayn/encr/blob/master/LICENSE">
    <img alt="" src="https://img.shields.io/npm/l/encr?style=for-the-badge&labelColor=000000">
  </a>
  <a aria-label="Donate via PayPal" href="https://amrayn.com/donate">
    <img alt="" src="https://img.shields.io/static/v1?label=Donate&message=PayPal&color=purple&style=for-the-badge&labelColor=000000">
  </a>
</p>

<p align="center">
    •   •   •
</p>

## Installation

```bash
npm i encr -S
```

```bash
yarn add encr
```

## CLI

```bash
## Encrypt
encr -i <input> -o <output> [--force] [--key <secret>] [--alg <algorithm>]

## Decrypt
encr -d -i <input> -o <output> [--force] [--key <secret>] [--alg <algorithm>]

## Random generator of length (default = 32)
encr -g <length>
```

### Arguments

| **Arg** | **Description** |
|--|--|
| `-i` | Input file - this can be encrypted or plain data file |
| `-o` | Output file. If this option is `stdout` it is output as string. Do not use this option to store to file as this will corrupt the encoding of buffer |
| `-d` | Use this option to decrypt the input|
| `-g` | Generate nonce|
| `--key` | The secret key to use for encryption. Alternatively you can provide environment variable `ENCR_SECRET`. If none of these options are provided then you will be securely asked for the key |

Optional arguments

| **Arg** | **Description** |
|--|--|
| `--force` | If output file already exists, use this option to overwrite. |
| `--alg` | Encryption algorithm to use. List depends upon OpenSSL (as per Node.js docs) Run `openssl list -cipher-algorithms` to choose the possible option. You must choose 256 bit option for correct key length. **It defaults to AES-256 CBC** |
| `-h` | Display this list of options for convenience |
| `-v` | Display version information |

## API
```
const Encr = require('encr');

const encr = new Encr('MySecret');
const plain = Buffer.from('Hello world');

encr.encrypt(plain).then(encrypted => {
  console.log('Encrypted:', encrypted.toString('base64'));
  return encr.decrypt(encrypted);
}).then(decrypted => {
  console.log('Decrypted:', decrypted.toString());
})
```

## License
```
Copyright (c) 2020 @abumusamq
https://amrayn.com

https://github.com/amrayn/

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

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