hex-my-bytes
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

hex-my-bytes Release Version

Convert a list of bytes to a HEX string, and vice versa

Build Status Coverage Status

Can be useful for debugging instances of TypedArray.

Install

$ npm install hex-my-bytes

Or if you prefer using Yarn:

$ yarn add hex-my-bytes

Usage

import { toHex, toBytes } from 'hex-my-bytes'
 
toHex([ 155, 56, 172, 62, 195, 70 ])
// => '9b38ac3ec346'
 
toBytes('9b38ac3ec346')
// => Uint8Array [ 155, 56, 172, 62, 195, 70 ]

API

toHex(bytes)

Convert an array of bytes to a lowercased hexadecimal string.

bytes

Type: number[]

A list of bytes.

Notes:

  • Only the first 8 bits of the numbers are used while generating the string.

toBytes(hexString)

Convert a hexadecimal string to a list of bytes, creating a new instance of Uint8Array.

hexString

Type: string

A hexadecimal string representing bytes.

Throws a TypeError if the argument is not the correct type or if its length is an odd number.

Browser support

The latest version of Chrome, Firefox, and Safari.

Node.js support

hex-my-bytes requires Node.js 11 or later, but it indicates Node.js 8 in package.json so you can use it with Node.js 8 by polyfilling the globals without having Yarn fail on install.

Readme

Keywords

none

Package Sidebar

Install

npm i hex-my-bytes

Weekly Downloads

17

Version

1.0.0

License

MIT

Unpacked Size

5.83 kB

Total Files

6

Last publish

Collaborators

  • macarie