Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hex_dump( inFile, outFile )
- if not fs.exists( inFile ) then error("Input file does not exist", 2) end
- local fInput = fs.open( inFile, "r" )
- local text = fInput.readAll()
- fInput.close()
- local fOutput = fs.open( outFile, "w" )
- local output = ""
- for i = 1, #text, 16 do
- local set = text:sub(i, i + 15)
- output = output..string.format( '%08X ', i - 1 )
- set:gsub('.', function (c) output = output..string.format('%02X ',c:byte() ) end)
- output = output..string.rep( ' ' ,3 * ( 16 - #set ) )
- output = output..' '..set:gsub( '%c', '.' ).."\n"
- end
- fOutput.write(output)
- fOutput.close()
- end
Add Comment
Please, Sign In to add comment