Voder-Vocoder

The Log of Hal Canary

Navigation: Home | THE LOG | Log Archives | Resume | Contact Info | Public Key | SSL | Math Applets | Site Map | WP Backend | RSS2 | Atom

« widow’s walk | randpassphrase »

hexer

/*  hexer - Convert  binary files to hexadecimal
    Copyright 2007 Hal Canary
    Dedicated to the Public Domain. */
/*  cc -o hexer hexer.c */
#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[]) {
  int i=0;
  char x;
  while (fread(&x, sizeof(x), 1, stdin) == 1) {
    i++;
    printf("%02hhx",x);
    if (i % 32 == 0) {
      printf("\n");
    }
  }
  printf("\n");
  return(0);
}
/*EOF*/

Or:

#!/bin/sh
exec hexdump -e '32/1 "%02x" "\n"' "$@"

Hal Canary | Computers & Code | 2007-03-11 10:16:41 EDT
Permanent Link | No Comments

Comments are closed.

Copyright 1997-2007 by Hal Canary.
mailto: h3 at halcanary dot org
xmpp:halcanary@jabber.org
aim:halwcanary
http://halcanary.org