First commit
This commit is contained in:
commit
fe250668fc
39
authenticator.py
Normal file
39
authenticator.py
Normal file
@ -0,0 +1,39 @@
|
||||
import pyotp
|
||||
import time
|
||||
import os
|
||||
|
||||
def clear_screen():
|
||||
os.system("cls" if os.name == "nt" else "clear")
|
||||
|
||||
def show_otp(issuer, account, secret):
|
||||
totp = pyotp.TOTP(secret)
|
||||
try:
|
||||
while True:
|
||||
clear_screen()
|
||||
current_otp = totp.now()
|
||||
time_remaining = totp.interval - (int(time.time()) % totp.interval)
|
||||
print("TOTP Authenticator\n")
|
||||
print(f"{issuer}\n{account}\n")
|
||||
print(current_otp)
|
||||
print(f"\nRemaining: {time_remaining:2} sec")
|
||||
for i in range(time_remaining, 0, -1):
|
||||
print(f"\rRefresh in: {i:2} sec", end="")
|
||||
time.sleep(1)
|
||||
if i == 1:
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
print("\nEND")
|
||||
|
||||
def app():
|
||||
issuer = None
|
||||
account = None
|
||||
secret = None
|
||||
try:
|
||||
show_otp(issuer, account, secret)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
|
Loading…
Reference in New Issue
Block a user