Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
BitBuf is a class library implementing an arbitrary bit-length (not necessarily byte aligned) buffers and bit level manipulation methods of such buffers.
A constructor for a BitBuf object of given length in bits.
A maximum size of a BitBuf in bits. This is enforced in constructor.
Creates a BitBuf from a string (of '1' and '0' characters) or Buffer or an integer. The parameter hint can be used in defining a bit length for the created BitBuf in case it is different from what could be derived directly from the source material. In particular, it can be used for allocating a BitBuf from integer with larger bit length that would be required for storing the said integer, and similarly for allocatong BigBuf from Buffer, it can be used for including only part of the bits in the Buffer for the resulting BitBuf. The illegal hint parameter is simply ignored.
Returns true, if parameter is a BitBuf object, otherwise false.
Returns a copy of a BitBuf.
Returns a value (0 or 1) of a bit in a given position within the BitBuf. The bits are indexed from 0 to BitBuf.length-1. The overflow causes an exception.
Set a value (0 or 1) to the bit in a given position within the BitBuf. If given value is not 0 or 1, the truth value is used automatically instead (val ? 1 : 0).
Toggle a value of the bit in a given position within the BitBuf (i.e. turn 0 to 1 and 1 to 0). This should be preferred to bb.set(pos, bb.get(pos) ? 0 : 1) because it's much faster, but the result is identical.
Concatenate the array of BitBuf objects to a new BitBuf.
Returns a string representation of a BitBuf i.e. a string consisting of '0' and '1' characters.
Returns an integer representation of a BitBuf. The maximum length of the BitBuf using this method, is 52 bits. Overflow causes an exception.
Performs an inplace logical AND operation for a BitBuf against the given BitBuf of the same length. Length mismatch causes an exception.
Performs an inplace logical OR operation for a BitBuf against the given BitBuf of the same length. Length mismatch causes an exception.
Performs an inplace inversion of all bits within a bitbuf. Returns the object itself.
Performs an inplace logical XOR (i.e. exclusive or) operation for a BitBuf against the given BitBuf of the same length. Length mismatch causes an exception.
Returns a new BitBuf representing a slice of the source BitBuf. If start offset is zero or omitted, it's the beginning of the BitBuf. If end offset is zero or omitted, it refers to the end of the BitBuf. Positive offsets are interpreted in relation to the beginning of the buffer and negative offsets are interpreted in relation the end of the buffer. Offset overflows cause exception.
Compares a BitBuf with a given other BitBuf of the same length and return -1, 0, 1 respectively if the BitBuf itself is smaller, identical, or bigger than the one given as parameter. The term bigger in this context is a BitBuf having a first 1 bit in a position where the other BitBuf has 0.
Performs an inplace bitwise shift operation in the BitBuf. The length of the BitBuf remains the same. Positive parameter shifts right and the negative one left.
Performs an inplace bitwise rotate operation in the BitBuf. The length of the BitBuf remains the same. Positive parameter rotates right and the negative one left.
Returns an internal Buffer object of the BitBuf object including the stored data. The length is guaranteed to be number of bytes fitting all the bits in the BitBuf but not having any extra bytes. Also bits in the last byte that do not represent a bit in the offset scope of the BitBuf, are guaranteed to be zero. (e.g. BitBuf.from('1').buffer() returns <Buffer 80>).
Timo J. Rinne tri@iki.fi
GPL-2.0
FAQs
A class for arbitrary bit length buffer with bit level operations.
The npm package bitbuf receives a total of 1 weekly downloads. As such, bitbuf popularity was classified as not popular.
We found that bitbuf 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.