Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
An xxhash binding for node.js.
npm install xxhash
var XXHash = require('xxhash');
var fs = require('fs');
var file = fs.readFileSync('somefile');
var result = XXHash.hash(file, 0xCAFEBABE);
var XXHash = require('xxhash');
var fs = require('fs');
var hasher = new XXHash(0xCAFEBABE);
fs.createReadStream('somefile')
.on('data', function(data) {
hasher.update(data);
})
.on('end', function() {
console.log('Hash value = ' + hasher.digest());
});
var HashStream = require('xxhash').Stream;
var fs = require('fs');
var hasher = new HashStream(0xCAFEBABE);
fs.createReadStream('somefile')
.pipe(hasher)
.on('finish', function() {
console.log('Hash value = ' + hasher.read());
});
hash(< Buffer >data, < mixed >seed[, < mixed >encbuf]) - mixed - Performs a single/one-time 32-bit hash of data
with the given seed
. seed
can be an unsigned integer or a Buffer containing (1 <= n <= 4) bytes to use for the seed. The resulting hash is returned. The format of the hash depends on the value of encbuf
. If encbuf
is a string and one of: buffer
, hex
, base64
, or binary
, then the hash value will be encoded in the appropriate format. If encbuf
is a Buffer of at least 4 bytes, then the hash value will be written to encbuf
and encbuf
will be returned. Otherwise, if encbuf
is not supplied, then the hash will be an unsigned integer.
hash64(< Buffer >data, < mixed >seed[, < mixed >encbuf]) - mixed - Performs a single/one-time 64-bit hash of data
with the given seed
. seed
can be an unsigned integer or a Buffer containing (1 <= n <= 8) bytes to use for the seed. The resulting hash is returned. The format of the hash depends on the value of encbuf
. If encbuf
is a string and one of: buffer
, hex
, base64
, or binary
, then the hash value will be encoded in the appropriate format. If encbuf
is a Buffer of at least 8 bytes, then the hash value will be written to encbuf
and encbuf
will be returned. The default value for encbuf
is 'buffer'
.
Stream(< mixed >seed[, < integer >bits][, < mixed >encbuf]) - DuplexStream - A stream constructor that takes in the seed
to use. Write data to the stream and when the stream ends, a bits
-bit (32 or 64) hash value (format determined by encbuf
) is available on the readable side. The values for seed
and encbuf
are described above in hash()
.
XXHash64(< mixed >seed) - This is the 64-bit Hash constructor. It is only needed if you want to use the old streaming interface (update()
/digest()
) instead of the streams2 interface described above.
(constructor)(< mixed >seed) - Creates and returns a new 32-bit Hash instance with the given seed
. The values for seed
are described above in hash()
.
update(< Buffer >data) - (void) - Update the hash using data
.
digest([< mixed >encbuf]) - mixed - The values for encbuf
and the resulting hash value format is described in hash()
.
FAQs
An xxhash binding for node.js
The npm package xxhash receives a total of 5,185 weekly downloads. As such, xxhash popularity was classified as popular.
We found that xxhash 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 found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.