Fairly recently there has been a change to the implementation of Bytes.toHex in base, and it has introduced a regression for any byte whose value is less than 0x10.
Example:
1 | > lib.base.Bytes.toHex 0xs0101
⧩
"11"
Here 0xs0101 represents two bytes: 01 01. But Bytes.toHex treats it as though it is the single byte 0x11 (17 in decimal notation). The problem is that each byte should be left-padded with 0 if it is a single character.
This problem did not exist with the previous implementation of Bytes.toHex:
3 | > catch do 0xs0101 |> Bytes.toBase16 |> fromUtf8
⧩
Right "0101"
Fairly recently there has been a change to the implementation of
Bytes.toHex
in base, and it has introduced a regression for any byte whose value is less than0x10
.Example:
Here
0xs0101
represents two bytes:01 01
. ButBytes.toHex
treats it as though it is the single byte0x11
(17
in decimal notation). The problem is that each byte should be left-padded with0
if it is a single character.This problem did not exist with the previous implementation of
Bytes.toHex
: