Hi,
I would like to know the easiest (but also the cleaner) way to convert hex to bytes.
My objective is to convert files to hex and those hex values to file again.
Converting files to hex was pretty easy but I did not find any solution for converting hex values back to bytes.
Any idea ?
import os, osproc, strutils
proc fileToHex(filename: string): string =
var f = open(filename, fmRead)
var content = f.readAll()
f.close()
return content.toHex()
proc hexToFile(data:string) =
writeFile("supertest.exe", data.parseHex())
echo fileToHex("./hello.exe")
The parseHex() method does not work because of expecting biggestInt.
Wow, I just did not read the docs well !
Many thanks !