Socket
Socket
Sign inDemoInstall

cipher-base

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

cipher-base

abstract base class for crypto-streams


Version published
Maintainers
1
Weekly downloads
8,507,553
decreased by-9.01%

Weekly downloads

Package description

What is cipher-base?

The cipher-base npm package is a module that provides a stream interface to transform data using cipher algorithms. It is typically used as a base for creating custom cipher implementations and can be used to encrypt or decrypt data in a streaming fashion.

What are cipher-base's main functionalities?

Stream-based encryption and decryption

This feature allows developers to create custom cipher implementations that can encrypt or decrypt data as it is streamed through the cipher. The code sample demonstrates how to inherit from CipherBase to create a custom cipher and implement the _update and _final methods for the encryption logic.

const CipherBase = require('cipher-base');
const inherits = require('util').inherits;

function MyCipher() {
  CipherBase.call(this);
}
inherits(MyCipher, CipherBase);

MyCipher.prototype._update = function (data) {
  // encryption logic here
  return data;
};

MyCipher.prototype._final = function () {
  // final block logic here
  return Buffer.alloc(0);
};

const myCipher = new MyCipher();
// Use myCipher as a stream to encrypt data

Other packages similar to cipher-base

Readme

Source

cipher-base

Build Status

Abstract base class to inherit from if you want to create streams implementing the same api as node crypto streams.

Requires you to implement 2 methods _final and _update. _update takes a buffer and should return a buffer, _final takes no arguments and should return a buffer.

The constructor takes one argument and that is a string which if present switches it into hash mode, i.e. the object you get from crypto.createHash or crypto.createSign, this switches the name of the final method to be the string you passed instead of final and returns this from update.

Keywords

FAQs

Last updated on 13 Sep 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc