npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

libeaes

v1.3.0

Published

Enhanced simultaneous compression + encryption with NodeJS

Downloads

57

Readme

libE-AES

Enhanced simultaneous compression + encryption

NPM Version NPM Downloads

NPM

Installing

Via NPM:

npm install libeaes

This installs a CLI binary accessible with the libeaes command.

# Check if libeaes command has been installed and accessible on your path
$ libeaes -v
v1.2.0

Usage

CLI

The libeaes command, using the algorithm, can perfectly process anything thrown at it. No matter the size. And give useful statistics at the end.

$ libeaes encrypt file.txt outputfile.enc
$ libeaes decrypt outputfile.enc outputfile.dec

# Piping output
$ libeaes encrypt movie.mp4 > movie.enc
# Stream an encrypted file in real time (e.g Watching the movie)
$ libeaes decrypt movie.enc | vlc -

Use --help to see full usage documentation. Use --help on specific commands to see docmentation for that command.

$ libeaes encrypt --help
$ libeaes decrypt --help

The commands can also be shortened to enc and dec respectfully.

$ libeaes enc file.txt output.enc
$ libeaes dec output.enc output.dec

Programmatically

// Node CommonJS
const libeaes = require('libeaes');
// Or ES6
import libeaes from 'libeaes';

Examples

Singular Operation

let password = "#P@$$W0R9";
let encrypted = libeaes.encrypt('Hello world', password);
// Compressed, encrypted content

let decrypted = libeaes.decrypt(encrypted, password);
// "Hello world"

Stream Operation

// Encrypt a stream, pipe output elsewhere
let encryptor = libeaes.EAESEncryptor("#P@$$W0R9");
inputStream.pipe(encryptor).pipe(outputStream);

// Decrypt a stream, pipe output elsewhere
let decryptor = libeaes.EAESDecryptor("#P@$$W0R9");
inputStream.pipe(decryptor).pipe(outputStream);

// Stream sequential encryption and decryption operations
let encryptor = libeaes.EAESEncryptor("#P@$$W0R9");
let decryptor = libeaes.EAESDecryptor("#P@$$W0R9");

inputStream.pipe(encryptor).pipe(decryptor).pipe(outputStream);
// inputStream == outputStream

File Operations

libeaes.encryptFileStream("rawfile.txt", "encryptedfile.txt", "#P@$$W0R9");
libeaes.decryptFileStream("encryptedfile.txt", "decryptedfile.txt", "#P@$$W0R9");

API

libeaes.encrypt(data, key)

Compress + Encrypt the input data, return the processed data

libeaes.decrypt(data, key)

Decrypt + Decompress the input data, return the processed data

libeaes.rawencrypt(data, key) *Excluding compression

Encrypt the input data, return the processed data.

Input data is encrypted without initial compression.

libeaes.rawdecrypt(data, key) *Excluding decompression

Decrypt raw input data, return the processed data.

Input data is assumed to be uncompressed.

Class: EAESEncryptor(key[, opts]) extends zlib.Gzip

Create a Transforming EAES Encryptor.

Data piped in here is compressed and encryped with the key configuration.

EAES Streams are encrypted, compressed streams that are tailored to the algorithm in this repo.

The opts object are passed directly into zlib.Gzip

Event: 'error'

This is emitted by either the compression or encryption process.

code is 1 when emitted by the encryption engine and undefined otherwise.

Catch errors explicitly with the 'error:compressor' and 'error:encryptor' events.

Event: 'error:encryptor'

The 'error:encryptor' event is emitted if an error occurred while encrypting compressed data. The listener callback is passed a single Error argument when called.

The stream is not closed when the 'error:encryptor' event is emitted.

Event: 'error:compressor'

The 'error:compressor' event is emitted if an error occurred while encrypting raw data. The listener callback is passed a single Error argument when called.

The stream is not closed when the 'error:compressor' event is emitted.

Class: EAESDecryptor(key[, opts]) extends zlib.Gunzip

Create an EAES Decryptor Stream.

Data piped in here is decrypted and decompressed with the key configuration.

EAES Streams are encrypted, compressed streams that are tailored to the algorithm in this repo.

The opts object are passed directly into zlib.Gunzip

Event: 'error'

This is emitted by either the decompression or decryption process.

code is 1 when emitted by the decryption engine and undefined otherwise.

Catch errors explicitly with the 'error:decompressor' and 'error:decryptor' events.

Event: 'error:decryptor'

The 'error:decryptor' event is emitted if an error occurred while decrypting decompressed data. The listener callback is passed a single Error argument when called.

The stream is not closed when the 'error:decryptor' event is emitted.

Event: 'error:decompressor'

The 'error:decompressor' event is emitted if an error occurred while decrypting raw data. The listener callback is passed a single Error argument when called.

The stream is not closed when the 'error:decompressor' event is emitted.

libeaes.encryptFileStream(infile, outfile, key)

Read the file, compress and encrypt each chunk, write to the outfile.

Returns the outputfile's stream object.

libeaes.decryptFileStream(infile, outfile, key)

Read the file, decrypt and decompress each chunk, write to the outfile.

Returns the outputfile's stream object.

ClI Info

  • When using pipes, it's not possible to seek through the stream
  • To avoid the terminal being cluttered while using pipes, direct other chained binaries (stdout, stderr) to /dev/null
# Watching from an encrypted movie, hiding vlc's log information
$ libeaes dec movie.enc | vlc - > /dev/null 2>&1

Development

Building

Feel free to clone, use in adherance to the license and perhaps send pull requests

git clone https://github.com/miraclx/libeaes-js.git
cd libeaes-js
npm install
# hack on code
npm run build
npm test

Testing

Tests are executed with Jest. To use it, simple run npm install, it will install Jest and its dependencies in your project's node_modules directory followed by npm run build and finally npm test.

To run the tests:

npm install
npm run build
npm test

License

Apache 2.0 © Miraculous Owonubi (@miraclx) <[email protected]>