SHARE
TWEET

Untitled

a guest Mar 4th, 2011 170 Never
  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
RAW Paste Data
Top