UNPKG

airgap-coin-lib

Version:

The airgap-coin-lib is a protocol agnostic library to prepare, sign and broadcast cryptocurrency transactions.

17 lines 813 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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' && hex_1.isHex(data) ? Buffer.from(data, 'hex') : Buffer.from(data); var hex = ''; for (var seed = 0; seed < chunks; seed++) { var hash = hex_1.toHexStringRaw(xxhash.h64(buffer, seed), 64); hex += config.littleEndian ? hex_1.changeEndianness(hash) : hash; } return config.withPrefix ? hex_1.addHexPrefix(hex) : hex; } exports.xxhashAsHex = xxhashAsHex; //# sourceMappingURL=xxhash.js.map