Last active
November 2, 2024 18:32
-
-
Save kezzyhko/ea5dcfd97be881d200e694731cb0c257 to your computer and use it in GitHub Desktop.
Tool for decoding binary messages from a screenshot of github's yearly commit chart [Dev Detour rickroll]
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
| from PIL import Image | |
| DELTA_X = 17 | |
| DELTA_Y = 17 | |
| START_X = 10 | |
| START_Y = 10 | |
| # https://stackoverflow.com/a/138260/6702274 | |
| im = Image.open('Untitled.png') | |
| pix = im.load() | |
| x = START_X | |
| y = START_Y | |
| c = 0 | |
| bits = "" | |
| string = "" | |
| while c < 1000: | |
| if x > im.size[0]: | |
| x = START_X | |
| y += DELTA_Y | |
| if y > im.size[1]: | |
| break | |
| color_red = pix[x, y][0] | |
| bit = "0" if color_red > 150 else "1" | |
| bits += bit | |
| if bits == "00000000": | |
| break | |
| if len(bits) == 8: | |
| string += chr(int(bits, 2)) | |
| bits = "" | |
| x += DELTA_X | |
| c += 1 | |
| print(string) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made for decoding a screenshot from this Dev Detour's video
https://youtu.be/_aDvNg9F6w8?t=178
It turned out to be a rickroll. Of course.