UNPKG

@airgap/coinlib-core

Version:

The @airgap/coinlib-core is a protocol agnostic library to prepare, sign and broadcast cryptocurrency transactions.

18 lines 863 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.xxhashAsHex = void 0; var xxhash = require("../dependencies/src/xxhashjs-0.2.2/lib/index"); var hex_1 = require("./hex"); function xxhashAsHex(data, bitLength, config) { if (config === void 0) { config = { littleEndian: true, withPrefix: false }; } var chunks = Math.ceil(bitLength / 64); var buffer = typeof data === 'string' && (0, hex_1.isHex)(data) ? Buffer.from(data, 'hex') : Buffer.from(data); var hex = ''; for (var seed = 0; seed < chunks; seed++) { var hash = (0, hex_1.toHexStringRaw)(xxhash.h64(buffer, seed), 64); hex += config.littleEndian ? (0, hex_1.changeEndianness)(hash) : hash; } return config.withPrefix ? (0, hex_1.addHexPrefix)(hex) : hex; } exports.xxhashAsHex = xxhashAsHex; //# sourceMappingURL=xxhash.js.map