Files

736 B

The use for this library 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"