Skip to content

toHex

Writes bytes as lowercase hexadecimal, two digits per byte. For content keys, hashes and debugging output.

Available since v3.1.10

import { toHex } from '@helpers4/binary';
// or, from the all-in-one package (same code, one install):
import { toHex } from 'helpers4/binary';
toHex(bytes: Uint8Array): string
ParameterTypeDescription
bytesUint8ArrayThe bytes

string — The hex string, twice as long as bytes

Two lowercase digits per byte.

toHex(new Uint8Array([0, 15, 255])) // => '000fff'

View source on GitHub