Skip to main content

@std/encoding@0.215.0

latest
Works with
It is unknown whether this package works with Node.js, Deno, Browsers, Cloudflare Workers, Bun
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score64%
Published2 years ago (0.215.0)

Port of the Go encoding/hex library.

This module is browser compatible.

Examples

Example 1

import {
  decodeHex,
  encodeHex,
} from "@std/encoding/hex";

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

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

Functions

f
decodeHex(src: string): Uint8Array

Decodes the given hex-encoded string. If the input is malformed, an error is thrown.

f
encodeHex(src: string | Uint8Array | ArrayBuffer): string

Converts data into a hex-encoded string.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/encoding

Import symbol

import * as mod from "@std/encoding/hex";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/encoding/hex";