1.0.2 • Published 4 years ago

to-byte-array v1.0.2

Weekly downloads
14
License
MIT
Repository
github
Last release
4 years ago

to-byte-array

Convert a string or buffer into a plain array of bytes

Why

This small package was first used throughout multiple repositories within the company I work at. In each of the instances, small changes were made sometimes, so we never knew which version was the right one.

This package simply prevents such mistakes from happening again.

Usage

This package only returns a function. That one functions accepts a string in either hexidecimal or base64url format. Whenever a non-hexidecimal character is encountered within the string, base64url is assumed (so no whitespace support in hexidecimal strings).

const toBytes = require('to-byte-array');

toBytes('DEADBEEF');   // [ 222, 173, 190, 239 ]
toBytes('deadbeef');   // [ 222, 173, 190, 239 ]
toBytes('HelloWorld'); // [  29, 233, 101, 161, 43, 149 ]
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago