Python: Binstream: Displays files binary


I guess everybody implements this once, here is mine: bitstream.py (py, 0 KB)

It produces a nice output like:

[user@thiscomputer Python]$ python ./bitstream.py /home/user/mysecretmsg.txt |head
0     0 1 0 1 0 1 0 0   84      0x54    T
1     0 1 1 0 1 0 0 0   104     0x68    h
2     0 1 1 0 1 0 0 1   105     0x69    i
3     0 1 1 1 0 0 1 1   115     0x73    s
4     0 0 1 0 0 0 0 0   32      0x20
5     0 1 1 0 1 0 0 1   105     0x69    i
6     0 1 1 1 0 0 1 1   115     0x73    s
7     0 0 1 0 0 0 0 0   32      0x20
8     0 1 1 1 0 0 1 1   115     0x73    s
9     0 1 1 0 1 1 1 1   111     0x6f    o

As you can see it shows byte number, binary, decimal, hexadecimal and ascii. Might be useful.

  1. No comments yet.
(will not be published)

  1. No trackbacks yet.