Skip to content

Instantly share code, notes, and snippets.

@inky
Created December 1, 2013 10:52
Show Gist options
  • Select an option

  • Save inky/7731934 to your computer and use it in GitHub Desktop.

Select an option

Save inky/7731934 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
HUMAN = 'beep boop'
ROBOT = '011000100110010101100101011100000010000001100010011011110110111101110000'
def splitbin(s):
for i in range(0, len(s), 8):
yield s[i : i + 8]
assert ROBOT == ''.join(bin(ord(c))[2:].zfill(8) for c in HUMAN)
assert HUMAN == ''.join(chr(int(b, 2)) for b in splitbin(ROBOT))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment