Skip to content

Instantly share code, notes, and snippets.

@ElliotFriend
Created May 24, 2021 14:33
Show Gist options
  • Save ElliotFriend/8e0451f0b03277867325de6f8a92eff7 to your computer and use it in GitHub Desktop.
Save ElliotFriend/8e0451f0b03277867325de6f8a92eff7 to your computer and use it in GitHub Desktop.
# what initially failed
n = 63
chunks = [jwt_token[i:i+n] for i in range(0, len(jwt_token), n)]
i = 0
jwt_dict = {}
while chunks:
index_data = f"{i:02d}"
key = index_data + chunks.pop(0)
last_char = key[-1]
key = key.rstrip(key[-1])
val = (last_char + chunks.pop(0)) if chunks else ''
jwt_dict[key] = val
i += 1
print(jwt_dict)
# what finally worked
n = 62
chunks = [jwt_token[i:i+n] for i in range(0, len(jwt_token), n)]
i = 0
jwt_dict = {}
while chunks:
index_data = f"{i:02d}"
key = index_data + chunks.pop(0)
# last_char = key[-1]
# key = key.rstrip(key[-1])
# val = (last_char + chunks.pop(0)) if chunks else ''
val = (chunks.pop(0)) if chunks else ''
jwt_dict[key] = val
i += 1
print(jwt_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment