UNPKG

837 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.U8_TO_HEX = exports.U16_TO_HEX = exports.HEX_TO_U8 = exports.HEX_TO_U16 = void 0;
7// Copyright 2017-2022 @polkadot/util authors & contributors
8// SPDX-License-Identifier: Apache-2.0
9const U8_TO_HEX = new Array(256);
10exports.U8_TO_HEX = U8_TO_HEX;
11const U16_TO_HEX = new Array(256 * 256);
12exports.U16_TO_HEX = U16_TO_HEX;
13const HEX_TO_U8 = {};
14exports.HEX_TO_U8 = HEX_TO_U8;
15const HEX_TO_U16 = {};
16exports.HEX_TO_U16 = HEX_TO_U16;
17
18for (let n = 0; n < 256; n++) {
19 const hex = n.toString(16).padStart(2, '0');
20 U8_TO_HEX[n] = hex;
21 HEX_TO_U8[hex] = n;
22}
23
24for (let i = 0; i < 256; i++) {
25 for (let j = 0; j < 256; j++) {
26 const hex = U8_TO_HEX[i] + U8_TO_HEX[j];
27 const n = i << 8 | j;
28 U16_TO_HEX[n] = hex;
29 HEX_TO_U16[hex] = n;
30 }
31}
\No newline at end of file