- Farmhash is really fast
- sha1 is the fastest hash in
crypto
sha1 (crypto) x 222,654 ops/sec ±2.06% (79 runs sampled)
md5 (crypto) x 196,396 ops/sec ±1.82% (78 runs sampled)
sha256 (crypto) x 155,714 ops/sec ±1.52% (82 runs sampled)
sha512 (crypto) x 168,394 ops/sec ±1.49% (82 runs sampled)
hash32 (farmhash) x 610,034 ops/sec ±1.32% (87 runs sampled)
hash64 (farmhash) x 470,859 ops/sec ±0.96% (83 runs sampled)
- hash-object has its own internal serialisation algorithm and sorts as it goes, crypto to generate the hash
- object-hash seems to stream the object into the crypto hashing functions, sorts object keys as they come up
- node-object-hash just sorts,
JSON.stringify
s and hashes - hash-obj just sorts,
JSON.stringify
s and hashes - Custom sort + stringify with farmhash 64-bit hash
Note that all the libraries had their algorithm set to sha1, some default to different ones
object-hash x 451 ops/sec ±1.31% (77 runs sampled)
node-object-hash x 9,097 ops/sec ±3.09% (79 runs sampled)
hash-obj x 7,950 ops/sec ±1.35% (85 runs sampled)
hash-object x 14,907 ops/sec ±1.98% (81 runs sampled)
sortKeys | JSON.stringify | farmhash x 6,322 ops/sec ±1.45% (82 runs sampled)