Skip to content

Instantly share code, notes, and snippets.

@tonigi
Created December 3, 2018 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonigi/020b98ad99f01854ac22caf235d9d338 to your computer and use it in GitHub Desktop.
Save tonigi/020b98ad99f01854ac22caf235d9d338 to your computer and use it in GitHub Desktop.
Replacement for xxd
#!/usr/bin/env python3
# Replaces xxd -i for systems without it (e.g. conda). Only stdin.
import sys
import textwrap
data=sys.stdin.buffer.read()
#xdata=", ".join([hex(x) for x in data])
xdata=", ".join([f'0x{y:02x}' for y in data])
print(textwrap.fill(xdata,75))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment