Skip to content

Buffer.from for the hex string #24491

Description

@nlapshin

I use the conversion to the hexadecimal number buffer as follows

   Buffer.from(number.toString(16), 'hex')

But, for number less that 16(15, 14 and so on) I get an empty buffer.

Example

   const buf = Buffer.from((5).toString(16), 'hex');
  
   console.log(buf); // <Buffer >

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidIssues and PRs that are invalid.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions