def getValues(pswd): teer() print("Youre services:\n") codes = fw.OpenJson("codes", pswd) for code in codes: print(code) teer() return codes
def add(pswd): ''' Add codes to codes.enc ''' name = input("Enter name of new service: ") secure_code = input("Secure code: ") codes = fw.OpenJson("codes", pswd) codes[name] = secure_code fw.SaveJson("codes", codes, pswd) totp = pyotp.TOTP(secure_code) print("Current code:", totp.now())
def addCodes(name, secure_code): ''' Add codes to codes.enc ''' if pwd.getPass() != None: try: codes = fw.OpenJson("codes", pwd.getPass()) except: codes = dict() codes[name] = secure_code fw.SaveJson("codes", codes, pwd.getPass()) else: botSendAdmin("Password Null")
def getCodes(checkName=None): """ If checkName is None sending list of (Name of Service + 2fa code) Else sending only 1 item with name 'checkName' + 2fa code for this service """ if pwd.getPass() is not None: try: codes = fw.OpenJson("codes", pwd.getPass()) for code in codes: if checkName == code: return generateCodes(codes[code]) if checkName is None: botSendAdmin(generateCodes(codes[code]) + "\n" + getTime()) time.sleep(1) except Exception as e: botSendAdmin("List of 2FA doesn't exist " + str(e)) return None else: botSendAdmin("Password Null")