Created
October 5, 2022 14:09
-
-
Save zulonas/027b448451ab4719f27d70d671cf280b to your computer and use it in GitHub Desktop.
hex dump for lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local function hex_dump(buf) | |
for byte=1, #buf, 16 do | |
local chunk = buf:sub(byte, byte + 15) | |
io.write(string.format('%08X ', byte - 1)) | |
chunk:gsub('.', function (c) io.write(string.format('%02X ', string.byte(c))) end) | |
io.write(string.rep(' ', 3 * (16 - #chunk))) | |
io.write(' ', chunk:gsub('%c', '.'), "\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment