Skip to content

Instantly share code, notes, and snippets.

@beli-sk
Created June 17, 2025 20:19
Show Gist options
  • Save beli-sk/e2f45e8af09fc71478b868b34cfa4dd8 to your computer and use it in GitHub Desktop.
Save beli-sk/e2f45e8af09fc71478b868b34cfa4dd8 to your computer and use it in GitHub Desktop.
TOTP URI decode
#!/usr/bin/env python
import sys
from base64 import b64decode, b32encode
from urllib.parse import urlparse, parse_qs
uri = urlparse(sys.argv[1])
q = parse_qs(uri.query)
data_b64 = q['data'][0]
data = b64decode(data_b64)
secret = data[4:].split(b'\x12', 1)[0]
print(b32encode(secret).decode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment