New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

to-byte-array

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-byte-array

Convert a string or buffer into a plain array of bytes

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

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 ]

FAQs

Package last updated on 20 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts