Skip to content

Instantly share code, notes, and snippets.

@ajdiaz
Created April 17, 2021 10:38
Show Gist options
  • Save ajdiaz/86af345e27b84b09536a05ac9b0161d0 to your computer and use it in GitHub Desktop.
Save ajdiaz/86af345e27b84b09536a05ac9b0161d0 to your computer and use it in GitHub Desktop.
Python script which convert plain text backup from Aegis OTP to andOTP
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2021 Andrés J. Díaz <ajdiaz@ajdiaz.me>
#
# Distributed under terms of the MIT license.
import sys
import time
import json
def main():
aegis = json.load(sys.stdin)
andotp = []
for item in aegis['db']['entries']:
andotp.append({
"secret": item['info']['secret'],
"issuer": item['issuer'],
"label": item['name'],
"digits": item['info']['digits'],
"type": item['type'].upper(),
"algorithm": item['info']['algo'],
"thumbnail": item['issuer'],
"last-used": int(time.time()),
"used_frequency": 0,
"period": item['info']['period'],
"tags": [],
})
print(json.dumps(andotp))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment