I have a 256-bit long but written as a little endian:
<Buffer 21 a2 bc 03 6d 18 2f 11 f5 5a bd 5c b4 32 a2 7b 22 79 7e 53 9b cb 44 5b 0e 00 00 00 00 00 00 00>
How can I correctly print it as a hexadeciaml value?
buf.toString('hex')
buk.toString('hex').split("").reverse().join(""))
gives 0x00000000000000e0b544bcb935e79722b72a234bc5dba55f11f281d630cb2a12
instead of 0x000000000000000e5b44cb9b537e79227ba232b45cbd5af5112f186d03bca221
You can use match
instead of split
to get an array of the two character groups. Then you can reverse the array and join it.
buf.toString('hex').match(/.{2}/g).reverse().join("")