...
bin_message += '0'
if g & 0b1 == 1:
bin_message += '1'
else:
bin_message += '0'
if b & 0b1 == 1:
bin_message += '1'
else:
bin_message += '0'
import binascii
# Such as this: http://www.rapidtables.com/convert/number/binary-to-ascii.htm
# http://stackoverflow.com/questions/7396849/convert-binary-to-ascii-and-vice-versa
def text_from_bits(bits, encoding='utf-8', errors='surrogatepass'):
n = int(bits, 2)
return int2bytes(n).decode(encoding, errors)
def int2bytes(integer):
hex_string = '%x' % integer
n = len(hex_string)
return binascii.unhexlify(hex_string.zfill(n + (n & 1)))
message = text_from_bits(bin_message)
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.