Created
April 3, 2018 01:26
-
-
Save muellermartin/081ca556985afc96b9a230ea5552d8b3 to your computer and use it in GitHub Desktop.
Script to decode the binary text of the Easterhegg 2018 logo
This file contains 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
import binascii | |
rabbit = '''\ | |
00 | |
110 | |
1100 | |
1100 | |
101 | |
001 | |
100 | |
11001 | |
1 00 | |
1000110 | |
11001100101 | |
010101111100 | |
00111011110 | |
0EASTERHEGG | |
01110012018 | |
001111010011 | |
00 010011101 | |
010 111001 | |
001 100111''' | |
def binlify(s): | |
result = 0 | |
for i, c in enumerate(reversed(s)): | |
c = ord(c) | |
# Convert ASCII one (or zero) to binary 1 (or 0) | |
# Create a large integer with each bit placed left to the previous one | |
# This is why we iterate in reverse order | |
result |= (c & 1) << i | |
return result.to_bytes((result.bit_length() + 7) // 8, 'big') | |
# Strip text and whitespace | |
code = rabbit.replace('2018', '').replace('EASTERHEGG', '') | |
code = code.replace(' ', '').replace('\n', '') | |
rabbit_bin = binlify(code) | |
# Why is n2n (short for "nerd2nerd") written is hex? | |
n2n = binascii.unhexlify(rabbit_bin[:6]).decode() | |
# Leave the rest as is | |
wuerzburg = rabbit_bin[6:].decode() | |
# Add yellow text color with ANSI escape codes | |
rabbit = rabbit.replace('EASTERHEGG', '\03[33;1mEASTERHEGG\033[0m') | |
rabbit = rabbit.replace('2018', '\033[33;1m2018\033[0m') | |
print(rabbit) | |
print() | |
print(n2n, wuerzburg) |
And here is a really cool visualization of the conversion from binary to hex/text: https://twitter.com/stefanpoertner/status/981912743526662144
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result (click me)