Last active
March 14, 2023 12:00
-
-
Save juanbretti/7e79dd1a1d367e6d369ff7f5353bd7a0 to your computer and use it in GitHub Desktop.
Convert TimeOtp from KeePass to Bitwarden or Vaultwarden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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