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

x/deno/std/encoding/hex.ts

A modern runtime for JavaScript and TypeScript.
Go to Latest
import * as deno from "https://deno.land/x/deno@v0.28.0/std/encoding/hex.ts";

Functions

Decode decodes src into decodedLen(src.length) bytes returning the actual number of bytes written to dst. Decode expects that src contains only hexadecimal characters and that src has even length. If the input is malformed, Decode returns the number of bytes decoded before the error.

DecodedLen returns the length of a decoding of x source bytes. Specifically, it returns x / 2.

DecodeString returns the bytes represented by the hexadecimal string s. DecodeString expects that src contains only hexadecimal characters and that src has even length. If the input is malformed, DecodeString will throws an error.

Encode encodes src into encodedLen(src.length) bytes of dst. As a convenience, it returns the number of bytes written to dst but this value is always encodedLen(src.length). Encode implements hexadecimal encoding.

EncodedLen returns the length of an encoding of n source bytes. Specifically, it returns n * 2.

EncodeToString returns the hexadecimal encoding of src.