-
Notifications
You must be signed in to change notification settings - Fork 24
/
authy.py
37 lines (28 loc) · 825 Bytes
/
authy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
import xml.etree.ElementTree as Et
import json
def fetch_json(filename):
tree = Et.parse(filename)
j = tree.find("string").text.replace(""", "\"")
return json.loads(j)
def object_to_cotp_json(d):
return [
{
'label': element['name'],
'secret': element['decryptedSecret'],
'issuer': "",
'type': "TOTP",
'digits': int(element['digits']),
'counter': 0,
"algorithm": "SHA1",
} for element in d
]
def main():
if len(sys.argv) != 3:
print("Usage: python authy.py [INPUT_FILE] [OUTPUT_FILE]")
return
data = fetch_json(sys.argv[1])
output_file = open(sys.argv[2], 'w')
output_file.write(json.dumps(object_to_cotp_json(data)))
output_file.close()
main()