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 getValues(pswd): teer() print("Youre services:\n") codes = fw.OpenJson("codes", pswd) for code in codes: print(code) teer() return codes
def change(codes): pswd_new = getpass.getpass("Enter new password: "******"Repeat your new password: "******"Passwords do not match") else: fw.SaveJson("codes", codes, pswd_new) print("Succeful password change") teer()
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")
def delete(codes, pswd): teer() print( "WARNING!\nTHIS ACTION MAY DELETE YOUR SECURE DATA\nPLEASE BE CAREFUL") teer() time.sleep(1) print("Enter name service that you want to delete:\n") service_name = input() if service_name not in codes: print("This key is not in the codes.enc") else: print("Are you sure want to delete %s ?" % service_name.upper()) ans = input() if ans == "yes" or ans == "y": shutil.copy2(r'codes.enc', r'codes.enc.OLD') del codes[service_name] fw.SaveJson("codes", codes, pswd) teer() print("Succeful delete!") teer()