Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
farmhash-modern
Advanced tools
FarmHash functions compiled using Rust and WebAssembly to make them easy to use in node.js and the browser
WASM/Web-Assembly implementation of Google's FarmHash family of very fast hash functions for use in node.js and the browser. FarmHash is the successor to CityHash. Functions in the FarmHash family are not suitable for cryptography.
The existing farmhash npm packge works great if you can get it to build, but this can create a lot of pain. This WASM build should work on any operating system that uses node.js with zero extra configuration. It should be 100% consistent across different platforms. You can even use it in the browser. This package also includes TypeScript types, and a handy bigqueryFingerprint
that matches BigQuery's FARM_FINGERPRINT
function.
This WASM implementation is built using the farmhash Rust Crate. The 64-bit APIs use JavaScript's BigInt type to represent results. If you need a base-10 string, you can simply call .toString()
on the result.
Install using npm or yarn.
npm install farmhash-modern
# or
yarn install farmhash-modern
Import using ES Module syntax or CommonJS syntax.
import * as farmhash from 'farmhash-modern';
console.log(farmhash.fingerprint32('hello world'));
or
const farmhash = require('farmhash-modern');
console.log(farmhash.fingerprint32('hello world'));
npm install farmhash-modern
# or
yarn install farmhash-modern
In your webpack.config.js
file, make sure you have set:
module.exports = {
// ...
experiments: {asyncWebAssembly: true},
// ...
};
Also, make sure you do not have any rules that will capture .wasm
files and turn them into URLs or some other format.
Import using ES Module syntax syntax.
import * as farmhash from 'farmhash-modern';
console.log(farmhash.fingerprint32('hello world'));
fingerprint32(input: string | Uint8Array): number
Create a new farmhash based u32 for a string or an array of bytes. Fingerprint value should be portable and stable across library versions and platforms.
fingerprint64(input: string | Uint8Array): bigint
Create a new farmhash based u64 for a string or an array of bytes. Fingerprint value should be portable and stable across library versions and platforms.
bigqueryFingerprint(input: string | Uint8Array): bigint
Create a new farmhash based i64 for a string or an array of bytes. Fingerprint value should be portable and stable across library versions and platforms.
This matches the format used by BigQuery's FARM_FINGERPRINT function.
hash32(input: string | Uint8Array): number
Create a new farmhash based u32 for an array of bytes. Hash value may vary with library version.
Create a new farmhash based u32 for an array of bytes with a given seed. Hash value may vary with library version.
hash64(input: string | Uint8Array): bigint
Create a new farmhash based u64 for an array of bytes. Hash value may vary with library version.
Create a new farmhash based u64 for an array of bytes with a given seed. Hash value may vary with library version.
yarn install
yarn build
cd web-app && npm install
cd web-app && npm build
MIT
FAQs
FarmHash functions compiled using Rust and WebAssembly to make them easy to use in node.js and the browser
The npm package farmhash-modern receives a total of 702,907 weekly downloads. As such, farmhash-modern popularity was classified as popular.
We found that farmhash-modern 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.