Convenience ES6 hashing library. Supports object, array and string hashing for md5 and sha256
NOTE: 2.0 can be considered a breaking change. The hashes being returned were non standard (ie. did not match externally generated md5s or shas). This is fixed, but the hashes returned will be different that v1, so will be incompatible with stored hashes.
$ npm install arc-hash --save
- supports md5 and sha256
- supports arrays and objects that reduce to scalar values
const ArcHash = require('arc-hash');
// This is an example complex object that reduces to scalar value
const exampleObject = {
'B': 5,
'D': {
'Zebra': 'Camel',
'Antelope': [0,2,
{
'Deep':'Mind'
},
['omega','alpha']
]
},
'A': 'Is a String',
};
console.log(ArcHash.md5(exampleObject));
/*
Output: 7d388f6ec86c79805a534c910471c7c7
Any change to the object including changing the order of an array, or changing the case in a key or a value will result in a new hash
*/
Take an unknown value and return an md5 hash representing it
Take an unknown value and return a sha256 hash representing it
- Array order matters for a hash, object order assignment does not.
- Keys and values are case sensitive
- Circular object references are not handled
- String() is eventually applied to all values, so 5 and '5' will not be seen as different values
- This is not incredibly performant, and should not be used for dynamic comparison over potentially large data sets
npm test