Last active
November 18, 2022 12:01
-
-
Save arHSM/b6a742efc37241129562e37a39e490c8 to your computer and use it in GitHub Desktop.
Instagram IDs are fun! (Lies)
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
APLPHABETS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_' | |
def id_to_code(id: int) -> str: | |
code = '' | |
while id > 0: | |
remainder = id % 64 | |
id = int((id - remainder) / 64) | |
code = APLPHABETS[remainder] + code | |
return code | |
def code_to_id(code: str) -> int: | |
id = 0; | |
for letter in code: | |
id = (id * 64) + APLPHABETS.index(letter) | |
return id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment