Gathering detailed insights and metrics for object-hash
Gathering detailed insights and metrics for object-hash
Gathering detailed insights and metrics for object-hash
Gathering detailed insights and metrics for object-hash
node-object-hash
Node.js object hash library with properties/arrays sorting to provide constant hashes
@types/object-hash
TypeScript definitions for object-hash
cache-base
Basic object cache with `get`, `set`, `del`, and `has` methods for node.js/javascript projects.
hash-it
Hash any object based on its value
Generate hashes from javascript objects in node and the browser.
npm install object-hash
Typescript
Module System
Min. Node Version
Node Version
NPM Version
99.3
Supply Chain
100
Quality
78.5
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
3,909,090,163
Last Day
1,637,595
Last Week
26,648,810
Last Month
115,606,240
Last Year
1,120,610,545
MIT License
1,452 Stars
222 Commits
148 Forks
11 Watchers
3 Branches
27 Contributors
Updated on Jun 30, 2025
Minified
Minified + Gzipped
Latest Version
3.0.0
Package Id
object-hash@3.0.0
Unpacked Size
57.48 kB
Size
17.81 kB
File Count
5
NPM Version
6.14.15
Node Version
14.18.0
Cumulative downloads
Total Downloads
Last Day
-13.9%
1,637,595
Compared to previous day
Last Week
-8.6%
26,648,810
Compared to previous week
Last Month
-1.6%
115,606,240
Compared to previous month
Last Year
27.6%
1,120,610,545
Compared to previous year
Generate hashes from objects and values in node and the browser. Uses node.js crypto module for hashing. Supports SHA1 and many others (depending on the platform) as well as custom streams (e.g. CRC32).
1var hash = require('object-hash'); 2 3hash({foo: 'bar'}) // => '67b69634f9880a282c14a0f0cb7ba20cf5d677e9' 4hash([1, 2, 2.718, 3.14159]) // => '136b9b88375971dff9f1af09d7356e3e04281951'
Starting with version 1.1.8
(released April 2017), new versions will consider
the exact returned hash part of the API contract, i.e. changes that will affect
hash values will be considered semver-major
. Previous versions may violate
that expectation.
For more information, see this discussion.
Generate a hash from any object or type. Defaults to sha1 with hex encoding.
algorithm
hash algo to be used: 'sha1', 'md5', 'passthrough'. default: sha1
crypto.getHashes()
. Note that the default of SHA-1 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.passthrough
algorith, which will return the information that would otherwise have been hashed.excludeValues
{true|false} hash object keys, values ignored. default: falseencoding
hash encoding, supports 'buffer', 'hex', 'binary', 'base64'. default: hexignoreUnknown
{true|*false} ignore unknown object types. default: falsereplacer
optional function that replaces values before hashing. default: accept all valuesrespectFunctionProperties
{true|false} Whether properties on functions are considered when hashing. default: truerespectFunctionNames
{true|false} consider name
property of functions for hashing. default: truerespectType
{true|false} Whether special type attributes (.prototype
, .__proto__
, .constructor
)
are hashed. default: trueunorderedArrays
{true|false} Sort all arrays before hashing. Note that this affects all collections,
i.e. including typed arrays, Sets, Maps, etc. default: falseunorderedSets
{true|false} Sort Set
and Map
instances before hashing, i.e. make
hash(new Set([1, 2])) == hash(new Set([2, 1]))
return true
. default: trueunorderedObjects
{true|false} Sort objects before hashing, i.e. make hash({ x: 1, y: 2 }) === hash({ y: 2, x: 1 })
. default: trueexcludeKeys
optional function for excluding specific key(s) from hashing, if true is returned then exclude from hash. default: include all keysHash using the sha1 algorithm.
Note that SHA-1 is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
Sugar method, equivalent to hash(value, {algorithm: 'sha1'})
Hash object keys using the sha1 algorithm, values ignored.
Sugar method, equivalent to hash(value, {excludeValues: true})
Hash using the md5 algorithm.
Note that the MD5 algorithm is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
Sugar method, equivalent to hash(value, {algorithm: 'md5'})
Hash object keys using the md5 algorithm, values ignored.
Note that the MD5 algorithm is not considered secure, and a stronger algorithm should be used if a cryptographical hash is desired.
Sugar method, equivalent to hash(value, {algorithm: 'md5', excludeValues: true})
Write the information that would otherwise have been hashed to a stream, e.g.:
1hash.writeToStream({foo: 'bar', a: 42}, {respectType: false}, process.stdout)
2// => e.g. 'object:a:number:42foo:string:bar'
node:
1npm install object-hash
browser: /dist/object_hash.js
1<script src="object_hash.js" type="text/javascript"></script> 2 3<script> 4 var hash = objectHash.sha1({foo:'bar'}); 5 6 console.log(hash); // e003c89cdf35cdf46d8239b4692436364b7259f9 7</script>
1var hash = require('object-hash'); 2 3var peter = { name: 'Peter', stapler: false, friends: ['Joanna', 'Michael', 'Samir'] }; 4var michael = { name: 'Michael', stapler: false, friends: ['Peter', 'Samir'] }; 5var bob = { name: 'Bob', stapler: true, friends: [] }; 6 7/*** 8 * sha1 hex encoding (default) 9 */ 10hash(peter); 11// 14fa461bf4b98155e82adc86532938553b4d33a9 12hash(michael); 13// 4b2b30e27699979ce46714253bc2213010db039c 14hash(bob); 15// 38d96106bc8ef3d8bd369b99bb6972702c9826d5 16 17/*** 18 * hash object keys, values ignored 19 */ 20hash(peter, { excludeValues: true }); 21// 48f370a772c7496f6c9d2e6d92e920c87dd00a5c 22hash(michael, { excludeValues: true }); 23// 48f370a772c7496f6c9d2e6d92e920c87dd00a5c 24hash.keys(bob); 25// 48f370a772c7496f6c9d2e6d92e920c87dd00a5c 26 27/*** 28 * hash object, ignore specific key(s) 29 */ 30hash(peter, { excludeKeys: function(key) { 31 if ( key === 'friends') { 32 return true; 33 } 34 return false; 35 } 36}); 37// 66b7d7e64871aa9fda1bdc8e88a28df797648d80 38 39/*** 40 * md5 base64 encoding 41 */ 42hash(peter, { algorithm: 'md5', encoding: 'base64' }); 43// 6rkWaaDiG3NynWw4svGH7g== 44hash(michael, { algorithm: 'md5', encoding: 'base64' }); 45// djXaWpuWVJeOF8Sb6SFFNg== 46hash(bob, { algorithm: 'md5', encoding: 'base64' }); 47// lFzkw/IJ8/12jZI0rQeS3w==
IE <= 8 and Opera <= 11 support dropped in version 0.3.0. If you require legacy browser support you must either use an ES5 shim or use version 0.2.5 of this module.
1git clone https://github.com/puleos/object-hash
If you want to stand this up in a docker container, you should take at look
at the project.
gulp watch
(default) watch files, test and lint on change/addgulp test
unit testsgulp karma
browser unit testsgulp lint
jshintgulp dist
create browser version in /distMIT
Only Node.js versions >= 6.0.0
are being tested in CI now.
No other breaking changes were introduced.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 18/28 approved changesets -- score normalized to 6
Reason
dependency not pinned by hash detected -- score normalized to 1
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
54 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More