Skip to content

Instantly share code, notes, and snippets.

@bensonk
Created September 13, 2011 01:08
Show Gist options
  • Save bensonk/1212902 to your computer and use it in GitHub Desktop.
Save bensonk/1212902 to your computer and use it in GitHub Desktop.
Ascii binary decoder
#!/usr/bin/env python
def chunk(s):
if s == "": return []
elif len(s) < 8: return [s]
else: return [s[:8]] + chunk(s[8:])
def decode(bin):
chars = [ chr(int(x, 2)) for x in chunk(bin) ]
return "".join(chars)
message = "0101001101101111001000000111010001110010011101010110010100101110"
print decode(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment