diff --git a/README.md b/README.md index cb8a19f..1230354 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,10 @@ Usually, a program expects input on stdin, and produces output on stdout. Flags are sparse by design. +Fluffy source code is purposefully spartan and easy to audit. +Forks are encouraged, +please let me know if you make one. + How To Build ------------ @@ -114,6 +118,15 @@ Removes duplicate frames from input, writing to output. +### hex: hex-encode input + +The opposite of `unhex`. + +The following is the equivalent of `cat`: + + hex | unhex + + ### printfesc: printf escape input Reads octets, diff --git a/hex.c b/hex.c new file mode 100644 index 0000000..4097a22 --- /dev/null +++ b/hex.c @@ -0,0 +1,22 @@ +#include + +int +main(int argc, char *argv[]) +{ + size_t count; + + for (count = 0; ; count += 1) { + int c = getchar(); + + if (EOF == c) { + break; + } + printf("%02x ", c); + if (7 == count % 8) { + putchar(' '); + } + } + putchar('\n'); + + return 0; +}