]> git.somenet.org - pub/jan/netsec2.git/blob - exercise2/task1/bitstobytes.py
Ex1 is now *really* done.
[pub/jan/netsec2.git] / exercise2 / task1 / bitstobytes.py
1 #!/usr/bin/python
2
3 from pprint import pprint
4
5 bits = "0100010001100001011101000110000100100000011000010110001101110001011101010110100101110010011001010110010000101110001000000100101101100101011110010010000001100110011011110111001000100000011011010110010101110011011100110110000101100111011001010010000000101000011011000110010101101110001111010011010000110010001000000010011000100000011100000110101101110100011100110011111000110010001100000011000000101001001110100010000001101110010100110110000100110001001100100011001100100000001010000101001101100011011011110111010001110100001010010010000001000"
6
7 bytelist = [ bits[i:i+8] for i in range(0, len(bits), 8) ]
8
9 solution = ""
10
11 for bchar in bytelist:
12     solution += chr(int(bchar, 2))
13
14 print ("%s" % solution)
15 print ("len: %d" % len(solution))