18 lines
454 B
Python
Executable file
18 lines
454 B
Python
Executable file
import json
|
|
|
|
from pyotp import TOTP
|
|
|
|
|
|
class OTPCredentials:
|
|
def __init__(self, name, realm, seed):
|
|
self.name = name # type: str
|
|
self.realm = realm # type: str
|
|
self.seed = seed # type: str
|
|
|
|
def get_json(self):
|
|
return {"name": self.name, "realm": self.realm, "token": TOTP(self.seed).now()}
|
|
|
|
|
|
def load_dump_pretty(content):
|
|
parsed = json.loads(content)
|
|
return json.dumps(parsed, indent=4, sort_keys=True)
|