Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sant123/hextools
Convert from ArrayBuffer to hexadecimal and viceversa in Deno.
https://github.com/sant123/hextools
arraybuffer deno hex
Last synced: about 1 month ago
JSON representation
Convert from ArrayBuffer to hexadecimal and viceversa in Deno.
- Host: GitHub
- URL: https://github.com/sant123/hextools
- Owner: sant123
- License: mit
- Created: 2021-11-02T05:30:54.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-21T02:17:10.000Z (over 1 year ago)
- Last Synced: 2024-09-17T15:28:15.776Z (about 2 months ago)
- Topics: arraybuffer, deno, hex
- Language: TypeScript
- Homepage:
- Size: 3.91 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hextools [![Deno](https://github.com/sant123/hextools/actions/workflows/deno.yml/badge.svg)](https://github.com/sant123/hextools/actions/workflows/deno.yml)
Convert from ArrayBuffer to hexadecimal and viceversa in Deno.
## Usage
```ts
// example.ts
import { bufferToHex, hexToBuffer } from "https://deno.land/x/hextools/mod.ts";const hex = bufferToHex(
new Uint8Array([
72,
101,
108,
108,
111,
32,
119,
111,
114,
108,
100,
]),
); // 48656c6c6f20776f726c64const buffer = hexToBuffer(hex);
console.log(new TextDecoder().decode(buffer)); // Hello world
```## API
### bufferToHex(buffer: ArrayBuffer): string
Converts from an ArrayBuffer to a hexadecimal string.
### hexToBuffer(hex: string): ArrayBuffer
Converts from a hexadecimal string to ArrayBuffer.
## Exceptions
### hexToBuffer(hex: string): ArrayBuffer
Throws a `TypeError` if hex length is not even or it has unrecognized
characters.