4 ms·
I tend to just use json-stable-stringify to get a consistent representation of JS objects. Then can hash or compare that. Browser: const crypto = window.
by tracker1 8y ago
I tend to just use json-stable-stringify to get a consistent representation of JS objects. Then can hash or compare that.
Browser:
const crypto = window.crypto || window.msCrypto; // IE11
return window.crypto.subtle.digest('SHA-256', stableStringify(obj));
Node:
require('crypto')
.createHash('sha256')
.update(pwd)
.digest('base64');
[1] https://www.npmjs.com/package/json-stable-stringify https://www.npmjs.com/package/json-stable-stringify