Hyperlinkv0.8.0-beta.28

Encoding

Encoding.encodeHexconsteffect/Encoding.ts:417
(input: Uint8Array | string): string

Encodes the given value into a hex string.

When to use

Use to encode text or bytes as lowercase hexadecimal text.

Example (Encoding hex strings and bytes)

import { Encoding } from "effect"

// Encode a string to hex
console.log(Encoding.encodeHex("hello")) // "68656c6c6f"

// Encode binary data to hex
const bytes = new Uint8Array([72, 101, 108, 108, 111])
console.log(Encoding.encodeHex(bytes)) // "48656c6c6f"
encoding
export const encodeHex: (input: Uint8Array | string) => string = (input) =>
  typeof input === "string" ? hexEncodeUint8Array(encoder.encode(input)) : hexEncodeUint8Array(input)
Referenced by 1 symbols