~martijnbraam/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] add contrib/andotp.py: import from andotp

Details
Message ID
<20211201135648.21198-1-sir@cmpwn.com>
DKIM signature
pass
Download raw message
Patch: +16 -0
This script converts the andOTP JSON dump into a list of otpauth://
URLs.
---
 contrib/andotp.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100755 contrib/andotp.py

diff --git a/contrib/andotp.py b/contrib/andotp.py
new file mode 100755
index 0000000..a98e004
--- /dev/null
+++ b/contrib/andotp.py
@@ -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)
-- 
2.34.1
Details
Message ID
<503df3d6-6d35-604e-d1e6-341e968792f8@brixit.nl>
In-Reply-To
<20211201135648.21198-1-sir@cmpwn.com> (view parent)
DKIM signature
missing
Download raw message
Thanks, applied to master

On 12/1/21 14:56, Drew DeVault wrote:
> This script converts the andOTP JSON dump into a list of otpauth://
> URLs.
> ---
>   contrib/andotp.py | 16 ++++++++++++++++
>   1 file changed, 16 insertions(+)
>   create mode 100755 contrib/andotp.py
>
> diff --git a/contrib/andotp.py b/contrib/andotp.py
> new file mode 100755
> index 0000000..a98e004
> --- /dev/null
> +++ b/contrib/andotp.py
> @@ -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)
Reply to thread Export thread (mbox)