Skip to content

Instantly share code, notes, and snippets.

@muellermartin
Created April 3, 2018 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muellermartin/081ca556985afc96b9a230ea5552d8b3 to your computer and use it in GitHub Desktop.
Save muellermartin/081ca556985afc96b9a230ea5552d8b3 to your computer and use it in GitHub Desktop.
Script to decode the binary text of the Easterhegg 2018 logo
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)
@muellermartin
Copy link
Author

Result (click me)

      00
     110
    1100
    1100
    101
    001
   100
 11001
 1  00
1000110
11001100101
 010101111100
   00111011110
    0EASTERHEGG
    01110012018
    001111010011
    00 010011101
   010   111001
  001   100111

n2n Würzburg

@muellermartin
Copy link
Author

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