Skip to content

Instantly share code, notes, and snippets.

@arHSM
Last active November 18, 2022 12:01
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 arHSM/b6a742efc37241129562e37a39e490c8 to your computer and use it in GitHub Desktop.
Save arHSM/b6a742efc37241129562e37a39e490c8 to your computer and use it in GitHub Desktop.
Instagram IDs are fun! (Lies)
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