UNPKG

parsec-node

Version:

https://parseclabs.readthedocs.io/en/latest/

22 lines (19 loc) 479 B
const { createHash } = require('crypto'); module.exports = function generateNetworkId(...args) { const networkId = createHash('sha256'); const data = args .map(el => { if (el instanceof Array) { return el.map(f => { if (typeof f === 'function') { return f.toString(); } return ''; }); } return el; }) .map(JSON.stringify) .join(); return networkId.update(data).digest('hex'); };