New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@vates/json-hash

Package Overview
Dependencies
Maintainers
11
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vates/json-hash

Compute a stable hash from a JSON-ifiable value

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
68
9.68%
Maintainers
11
Weekly downloads
 
Created
Source

@vates/json-hash

Package Version License PackagePhobia Node compatibility

Compute a stable hash from a JSON-ifiable value

Install

Installation of the npm package:

npm install --save @vates/json-hash

Usage

The use for this librariy is to create a composite key from a JSON value, ignoring objects identity and properties order.

The hash algorithm used is intended to be fast and with low collisions and is not guaranteed to be be secure.

The hash is encoded using Base64 URL to make it easy to use in URLs and filenames.

import { jsonHash } from '@vates/json-hash'

console.log(jsonHash('foo'))
// → "siEyldVkkW-JpqQkVVZ8h8P0gPzXocFeIg8X1xaaeQs"

// order of properties is ignored
console.log(jsonHash({ foo: 0, bar: 1 }))
// → "JckoRSMIBjNlgEWIXhgpBOuyLQYqABZqvf1ccb3BPg0"
console.log(jsonHash({ bar: 1, foo: 0 }))
// → "JckoRSMIBjNlgEWIXhgpBOuyLQYqABZqvf1ccb3BPg0"

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

ISC © Vates SAS

Keywords

hash

FAQs

Package last updated on 05 Aug 2024

Did you know?

Socket

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