0110100001110100011101000111000000111010001011110010111101111000011010110110001101100100001011100110001101101111011011010010111100110101001100010011100000101111
Seriously, you really want to know what’s behind this!
BuHa.info’s New Year’s Challenge gave me the feeling that I quickly have to write a Python script, decoding ones and zeros to text, using ASCII code :-)
import sys
# define file pointers and bytelength
file_in = open("bin2txt_in.txt")
file_out = open("bin2txt_out.txt","wb")
bl = 8
# read input file; remove whitespaces
# make list of bits (ints) from input
bitlist = map(int,''.join(file_in.read().split()))
if len(bitlist)%bl != 0:
sys.exit("length of bitlist not integer multiple of %s" % bl)
# assemble resultstring:
# - make list of bytes from `bitlist`
# - evaluate each byte -> int -> ascii char
rs = ''.join([chr(sum(bit<<abs(idx-bl)-1 for idx,bit in enumerate(y)))
for y in zip(*[bitlist[x::bl] for x in range(bl)])
])
# write output
file_out.write(rs)
file_out.close()
Put the data above in bin2txt_in.txt
, run the script(*) in the same directory and read bin2txt_out.txt
‘s content. You won’t regret.
(*)For Windows users not knowing how to run the script:
– Download Python & install it.
– Copy the script above into a simple text file with the extension .py
and doubleclick to run.
And, yeah, you’re right, this is senseless (except for the programming exercise). And.. true, you can decode this using online converters like this one here.
Leave a Reply