~martijnbraam/numberstation

c38ff62143e86df7a83ef718dbe89fbb26b70ffc — Drew DeVault 2 years ago f213005
add contrib/andotp.py: import from andotp

This script converts the andOTP JSON dump into a list of otpauth://
URLs.
1 files changed, 16 insertions(+), 0 deletions(-)

A contrib/andotp.py
A contrib/andotp.py => contrib/andotp.py +16 -0
@@ 0,0 1,16 @@
#!/usr/bin/env python3
from urllib.parse import quote
import json
import sys

items = json.load(sys.stdin)
for item in items:
    if item["type"] != "TOTP":
        sys.stderr.write(f"Unknown code type {item['type']}\n")
    label = quote(item["label"])
    secret = item["secret"]
    url = f"otpauth://totp/{label}?secret={secret}"
    if item["issuer"]:
        issuer = quote(item["issuer"])
        url += f"&issuer={issuer}"
    print(url)