Advertisement
Guest User

Untitled

a guest
Mar 4th, 2011
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement