diff --git a/contrib/README.md b/contrib/README.md new file mode 100644 index 0000000..e2338e4 --- /dev/null +++ b/contrib/README.md @@ -0,0 +1,10 @@ +tiny tool to export the set of secrets in .2fa into text file for [Authenticator Pro](https://stratumauth.com/) + +usage: +```bash +./path-to/rsc2authpro.py .2fa > uris.txt +``` + +normally it prints into stdout set of secrets in form similar to + +otpauth://totp/Example:alice@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example diff --git a/contrib/rsc2authpro.py b/contrib/rsc2authpro.py new file mode 100755 index 0000000..0795b2c --- /dev/null +++ b/contrib/rsc2authpro.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +import sys + +def convert_rsc_config_to_otpauth(config_path): + with open(config_path, 'r') as f: + for line in f: + parts = line.strip().split() + if len(parts) == 3 and parts[1] == '6': + label, digits, secret = parts + otpauth = f"otpauth://totp/{label}:{label}?secret={secret}&issuer={label}&digits=6" + print(otpauth) + +if len(sys.argv) < 2: + print("Usage: python rsc2authpro.py ~/.2fa") + sys.exit(1) +convert_rsc_config_to_otpauth(sys.argv[1])