# aes-encrypt-stream

> Implement aes-256-ctr encryption/decryption with stream

Latest version **0.2.0** (published 2020-08-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install aes-encrypt-stream
pnpm add aes-encrypt-stream
yarn add aes-encrypt-stream
bun add aes-encrypt-stream
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-08-31 |
| First published | 2020-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | wangsijie |
| Maintainers | wangsijie |

## Links

- npm: https://www.npmjs.com/package/aes-encrypt-stream
- Repository: https://github.com/wangsijie/aes-encrypt-stream
- Homepage: https://github.com/wangsijie/aes-encrypt-stream#readme
- Issues: https://github.com/wangsijie/aes-encrypt-stream/issues
- npm.io page: https://npm.io/package/aes-encrypt-stream

## Recent versions

- 0.2.0 (latest) — 2020-08-31
- 0.1.0 — 2020-02-15

## README

# aes-encrypt-stream

Implement aes-256-ctr encryption/decryption with stream. Automaticly generate IV for each encryption and store iv(16 bytes) in the start of the encyrpted data.

## Instalation

```
npm i aes-encrypt-stream
```

## Basic Usage

```js
const fs = require('fs');
const { createEncryptStream, createDecryptStream, setPassword } = require('aes-encrypt-stream');

// password: 256 bit buffer
setPassword(Buffer.from('f8647d5417039b42c88a75897109049378cdfce528a7e015656bd23cd18fb78a', 'hex'));

// encrypt
createEncryptStream(fs.createReadStream('origin.txt')).pipe(fs.createWriteStream('encrypted.txt'))

// decrypt
// fs.createReadStream('encrypted.txt').pipe(createDecryptStream(fs.createWriteStream('decrypted.txt')));

```

## Generate Password

```js
const { generatePassword } = require('aes-encrypt-stream');
console.log(generatePassowrd().toString('hex'));
```

## Advanced Usage

Used with express to send decrypted data stream:

```js
const express = require('express');
const fs = require('fs');
const { createDecryptStream, setPassword } = require('aes-encrypt-stream');

setPassward(Buffer.from('f8647d5417039b42c88a75897109049378cdfce528a7e015656bd23cd18fb78a', 'hex'));

const app = express();
app.get('/', (req, res) => {
    const readStream = fs.createReadStream('encrypted.txt');
    readStream.pipe(createDecryptStream(res));
});

app.listen(3000);
```

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