Skip to main content
Module

std/encoding/hex.ts

Deno standard library
Go to Latest
import * as mod from "https://deno.land/std@0.41.0/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.