1
0
Fork 0
gist/otp_conv.py

20 lines
607 B
Python

#! /usr/bin/python3
"""
Convert Bitwarden Vault JSON exports OTP tokens into otpauth-Links
"""
import json
f = open("bitwarden_export.json", "r", encoding="utf-8")
data = json.load(f)
for item in data['items']:
if 'login' in item:
if 'totp' in item['login']:
if item['login']['totp']:
if item['login']['totp'].startswith('otpauth'):
print(item['login']['totp'])
else:
print('otpauth://totp/'+str(item['login']['username'])+'?secret='+str(item['login']['totp'].replace(' ',''))+'&issuer='+str(item['name']))