Advertisement
Duffscs

Untitled

Mar 31st, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. -- compact/one-line form (note: all strings in '', so you can run it with: lua -e "..." )
  2. s=' 01234567 89abcdef\n' for y=0,0xf0,0x10 do s=s..('%02x '):format(y) for x=0,0xf do s=s..string.char(y+x):gsub('%c','.') if x==7 then s=s..' ' end end s=s..(' %02x\n'):format(y) end print(s)
  3.  
  4. -- expanded/pretty-printed form
  5. s=' 01234567 89abcdef\n'
  6. for y=0,0xf0,0x10 do
  7. s=s..('%02x '):format(y)
  8. for x=0,0xf do
  9. s=s..string.char(y+x):gsub('%c','.')
  10. if x==7 then
  11. s=s..' '
  12. end
  13. end
  14. s=s..(' %02x\n'):format(y)
  15. end
  16. print(s)
  17.  
  18. -- slightly smaller, less functional, more obfuscated variant
  19. s=(('.'):rep(0x7f-0x1f):gsub('().',function(x) return string.char(0x1f+x) end):gsub('()('..('.'):rep(0x8)..')', function(i,l) return ('0x%02x %s\n'):format(i+0x20-1,l) end))
  20. print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement