Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
cipher-base
Advanced tools
abstract base class for crypto-streams
Weekly downloads
Package description
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.
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
The 'crypto' module is a built-in Node.js module that provides cryptographic functionality including a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. Unlike cipher-base, which is a base class for creating custom cipher streams, 'crypto' provides a more comprehensive set of cryptographic operations out of the box.
The 'bcrypt' npm package is a library for hashing passwords. It is designed to be a secure and adaptive hashing algorithm. While cipher-base is used for creating custom cipher streams, 'bcrypt' is specifically focused on password hashing and does not provide a streaming interface.
The 'aes-js' npm package is a pure JavaScript implementation of the AES block cipher algorithm and all common modes of operation (CBC, CFB, CTR, ECB, OFB). It differs from cipher-base in that it provides specific implementations of AES rather than a base class for creating custom ciphers.
Readme
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.
FAQs
abstract base class for crypto-streams
The npm package cipher-base receives a total of 6,971,938 weekly downloads. As such, cipher-base popularity was classified as popular.
We found that cipher-base demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.