get-obj-hash
v1.0.0
Published
Get the hash of a object or primitive using BLAKE2b or BLAKE2s
Downloads
2
Readme
get-obj-hash
Get the hash of a object or primitive using BLAKE2b or BLAKE2s
Table of Contents
Install
This project uses node and npm.
$ npm install get-obj-hash
$ # OR
$ yarn add get-obj-hash
Usage
import getObjHash from 'get-obj-hash'
console.log(getObjHash({ foo: 'bar' }, 'blake2bHex')) // 69ba2f27abe30569cdccad25b58ec54899e77032f765d703a1cd5adcb5dd1158e999ba8325d9c770bff17ae175c220842196a83441a8a146e7bfdc9309955ae6
console.log(getObjHash({foo: 'bar'})) // 09da64c8bf2f8d35f455427593f1cec83a2f5dc297b9bfe9564cd405cd8eedf7
console.log(getObjHash(5)) // 9019e532fa6da4ab4ae2980b2102d79af81e5ccb481bdd6a3c9cdc0f10fe60ee
console.log(getObjHash(true)) // 3aa997a5c6f560fe2ccb5bad11d985987a18bffe9b3b17524cb47a37f4a3bd14
Also useful for keys in React:
import React from 'react'
import getObjHash from 'get-obj-hash'
const Example = ({listOfObjects}) =>
listOfObjects.map(current =>
<div key={getObjHash(current)}>{current.name}</div>)
Contribute
- Fork it and create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am "Add some feature"
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
License
MIT