Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 4th, 2011  |  syntax: Python  |  size: 0.42 KB  |  hits: 162  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import sys
  2.  
  3. def ByteToHex(byteStr): return '%02X' % ord(byteStr)
  4.  
  5. try:
  6.     counter = {}
  7.  
  8.     for bytes in open(sys.argv[1], "rb").read():
  9.         counter[ByteToHex(bytes)] = counter.get(ByteToHex(bytes), 0) + 1
  10.  
  11.     peak = max(counter.values())
  12.  
  13.     for key, value in sorted(counter.items(), key=lambda x:(x)):
  14.         print '%s: %06d %s' % (key, value, '-' * (68 * value/peak))
  15.  
  16. except Exception, e:
  17.     print e