Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/lume/deps/hex.ts

🔥 Static site generator for Deno 🦕
Very Popular
Go to Latest
import * as lume from "https://deno.land/x/lume@v1.19.0/deps/hex.ts";

Port of the Go encoding/hex library.

This module is browser compatible.

Examples

Example 1

import {
  decodeHex,
  encodeHex,
} from "https://deno.land/std@0.224.0/encoding/hex.ts";

const binary = new TextEncoder().encode("abc");
const encoded = encodeHex(binary);
console.log(encoded);
// => "616263"

console.log(decodeHex(encoded));
// => Uint8Array(3) [ 97, 98, 99 ]

Functions

Decodes src into src.length / 2 bytes. If the input is malformed, an error will be thrown.

Decodes the given hex string to Uint8Array. If the input is malformed, an error will be thrown.

Encodes src into src.length * 2 bytes.

Encodes the source into hex string.