Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aes-encrypt-stream

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aes-encrypt-stream

Implement aes-256-ctr encryption/decryption with stream

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

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

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

Advanced Usage

Used with express to send decrypted data stream:

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);

FAQs

Package last updated on 31 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc