# hex-array

> Create Uint8Array buffers from hexadecimal strings, and vice versa.

Latest version **1.0.0** (published 2017-06-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install hex-array
pnpm add hex-array
yarn add hex-array
bun add hex-array
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-06-17 |
| First published | 2017-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/hex-array) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | colinbarry |
| Maintainers | colinbarry |
| Keywords | hex, buffer, Uint8Array, hexadecimal, string, conversion |

## Links

- npm: https://www.npmjs.com/package/hex-array
- Repository: https://github.com/colinbarry/hex-array
- Homepage: https://github.com/colinbarry/hex-array#readme
- Issues: https://github.com/colinbarry/hex-array/issues
- npm.io page: https://npm.io/package/hex-array

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2017-06-17

## README

hex-array
=========

Creates Uint8Array buffers from hexadecimal strings, and vice versa.

## Installation

  npm install hex-array

## Usage
```javascript
  var hexarray = require('hex-array');
  hexarray.toString(new Uint8Array([0xc9, 0x13, 0x4b, 0xca,
                                    0x6a, 0x49, 0xfc, 0xf8,
                                    0x2d, 0x30, 0x3b, 0x4e,
                                    0xa0, 0x26, 0x3a, 0xd8]);
  // = C9134BCA6A49FCF82D303B4EA0263AD8

  hexarray.fromString("C9134BCA6A49FCF82D303B4EA0263AD8");     
  // = Uint8Array [ 201, 19, 75, 202, 106, 73, 252, 248, 45, 48, 59, 78, 160, 38, 58, 216 ]
```

## Methods

## `hexarray.toString(array, [options])`
  converts the given buffer to a string containing its hexadecimal
  representation.

  `array` a Uint8Array buffer to convert.

  `options` an optional object with the following members:

  * `grouping` this number of hex bytes are grouped together with spaces between
  groups. 0 means no grouping is applied. 0 if unspecified.

  * `rowlength` the number of groups which make up a row. When 0, no splitting
  into rows occurs. 0 if unspecified.

  * `uppercase` if true, the output will be in uppercase. true by default.


  `return` a hexadecimal string representing the buffer.


## `hexarray.fromString(string)`
  takes a string containing hexadecimal and returns the equivalent as a
  Uint8Array buffer.

  `string` The string to convert. Whitespace is ignored. If an odd number of
  characters are specified, it will act as if preceeded with a leading 0; that
  is, "FFF" is equivalent to "0FFF".

  `return` a Uint8Array array.


## Tests

  npm test

---
_Source: https://npm.io/package/hex-array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
