Skip to content

Instantly share code, notes, and snippets.

@juanbretti
Last active March 14, 2023 12:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanbretti/7e79dd1a1d367e6d369ff7f5353bd7a0 to your computer and use it in GitHub Desktop.
Save juanbretti/7e79dd1a1d367e6d369ff7f5353bd7a0 to your computer and use it in GitHub Desktop.
Convert TimeOtp from KeePass to Bitwarden or Vaultwarden
import json
data = json.load(open("bitwarden_export_20221019000142.json", encoding='utf-8'))
totp_keepass = "TimeOtp-Secret-Base32"
# data['items'][2]['fields'][0]['name'] == totp_keepass
i = 0
for index1, value1 in enumerate(data['items']):
if 'fields' in value1:
# print('value1', value1, "\n"*5)
for index2, value2 in enumerate(value1['fields']):
if 'name' in value2:
# print('value2', value2, "\n"*5)
if value2['name'] == totp_keepass:
data['items'][index1]['login']['totp'] = value2['value']
del data['items'][index1]['fields'][index2]
i += 1
print(f'Moved {i} times')
with open("bitwarden_export_20221019000142_mod.json", 'w', encoding='utf-8') as f:
json.dump(data, f, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment