@polkadot/extension-inject
Version:
A generic injector (usable to any extension), that populates the base exposed interfaces to be used by dapps.
17 lines (16 loc) • 732 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.cyrb53 = cyrb53;
function cyrb53(input, seed = Date.now()) {
let h1 = 0xdeadbeef ^ seed;
let h2 = 0x41c6ce57 ^ seed;
for (let i = 0, count = input.length; i < count; i++) {
const ch = input.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
// https://stackoverflow.com/a/52171480
return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
}
;