Created
September 13, 2011 01:08
-
-
Save bensonk/1212902 to your computer and use it in GitHub Desktop.
Ascii binary decoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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