I seem to be able to find information on how to do this in C#, but not on how to perform the same operation in Python.
Any advice or suggestions would be appreciated. Thank you very much.
I seem to be able to find information on how to do this in C#, but not on how to perform the same operation in Python.
Any advice or suggestions would be appreciated. Thank you very much.
def padded_bin(number, width=8, padchar='0'):
return bin(number)[2:].rjust(width, padchar)
with open(r'C:\path\to\file.txt', 'rb') as f:
as_binary = ''.join(padded_bin(ord(c)) for c in f.read())
''.join((map(''.join, itertools.product(*['01']*8))[ord(c)]
for c in open('foo').read()))
print "".join(bin(ord(c))[2:] for c in file("a.exe", "rb").read())
update with padding:
print "".join(("00000000"+bin(ord(c))[2:])[:8] for c in file("a.exe", "rb").read())