Deviopath › Node.js

Bytes to Hex

Easy · Buffers

In Node, buffer.toString("hex") turns bytes into a hex string with two characters per byte: Buffer.from([255, 0, 16]).toString("hex") is "ff0010".

Write a function toHex(bytes) that does the same for an array of numbers from 0 to 255. Use lowercase letters and always two characters per byte.

Next: UTF-8 Byte Length