コード例 #1
0
def main():
    guest_name = input("What is your name?")
    print(f"Hello {guest_name}, welcome to Password Locker:")
    print('\n')
    while True:
        print('\n')
        print(r"*"*30)
        print('\n')
        print("Use these short codes to navigate through Password_Locker:\n ln to log in \n ca to create a new account. \n ex to exit")
        print('\n')
        short_code = input().lower()
        if short_code == 'ca':
            print("New Account")
            print("-"*10)
            print("Enter First Name ...")
            first_name = input()
            print("Enter Last Name ...")
            last_name = input()
            print("Enter Phone Number ...")
            phone_number = input()
            print(" Enter Email Address ...")
            email = input()
            # p_word = input("Enter a password you can remember")
            print("Do you want to input your own password or have one generated for you? Use short codes\n'gp\' to generate password.\n \'cyo\' to choose your own password \n \'ex\' to exit... ")
            password_choice = input()
            password = ''
            if password_choice == 'cyo':
                password = password.join(
                    input("Enter a password of your choice..."))
                # break
            elif password_choice == 'gp':
                print("Enter the length of the password you wish to generate eg 9 ")
                pass_len = input()
                password = password.join(
                    Credential.generate_password(pass_len))
                # break
            elif password_choice == 'ex':
                break
            else:
                print("Sorry I did not get that. Please try again")
                # password = input("Enter a password of your choice...")
            # Create and save new user
            save_user(create_user(first_name, last_name,
                                  email, phone_number, password))
            print('\n')
            print(f"New Account for {first_name} {last_name} created.")
            print('\n')
            print(
                f"Your password is {password} :-Use it to log in using short code ln")
            print('\n')
        elif short_code == 'ln':
            print('\n')
            print("Enter your account details to log in: \n Enter your first name...")
            first_name = input()
            print("Enter your password...")
            password = input()
            account_exist = verify_user(first_name, password)
            if account_exist == first_name:
                print('\n')
                print(
                    f"Welcome to your Password locker account {first_name}: \n Please choose an option to continue...")
                print('\n')
                while True:
                    print('\n')
                    print("Navigation short codes: \n cc to create new credentials: \n dc to display credentials: \n sc to search credentials: \n rm to remove or delete credentials: \n copy to copy credentials: \n ex to exit")
                    print('\n')
                    short_code = input().lower()
                    if short_code == 'cc':
                        print('\n')
                        print("Enter your credential details")
                        print("Enter account type... eg \'google\'")
                        account_name = input()
                        print(f"Enter username ")
                        user_name = input()
                        print(f"Enter site name")
                        site_name = input()
                        print(
                            f"Enter the username you used or would love to use on {site_name}")
                        user_name = input()
                        while True:
                            print("Do you want to input your own password or have one generated for you? Use short codes\n'gp\' to generate password.\n \'cyo\' to choose your own password \n \'ex\' to exit... ")
                            password_choice = input()
                            if password_choice == 'cyo':
                                password = input(
                                    "Enter a password of your choice...")
                                break
                            elif password_choice == 'gp':
                                print(
                                    "Enter the length of the password you wish to generate eg 9 ")
                                pass_len = input()
                                pass_len = int(pass_len)
                                password = Credential.generate_password(
                                    pass_len)
                                break
                            elif password_choice == 'ex':
                                break
                            else:
                                print("Sorry I did not get that. Please try again")
                                
                        # return at_password
                        save_credentials(create_credential(
                            user_name, site_name, account_name, password))
                        print(' \n')
                        print(
                            f'Credential Created:\n Account type: {site_name}  \n Account Username: {user_name} \n Account Password: {password}')
                        print('\n ')

                    else:
                        print("I did not get that, please try again")
            else:
                print(
                    f"Sorry, we could not find any account under the name {first_name}")
                print('\n')
        elif short_code == 'ex':
            break
        else:
            print("I really did not get that, please use the short code ")
コード例 #2
0
def generate_password():
    '''
    Function to generate a password automatically
    '''
    gen_pass = Credential.generate_password()
    return gen_pass
コード例 #3
0
def generate_password(pass_len):
    '''
    A funtion to generate password, combining random letters and digits
    '''
    return Credential.generate_password(pass_len)
コード例 #4
0
ファイル: password.py プロジェクト: Sam-692/Password-Locker
def generate_password():
    """
    Function that generates a random password wit range
    """
    password = Credential.generate_password()
    return password
コード例 #5
0
def generate_password():
    '''
    function to give password randomly
    '''
    generate=Credential.generate_password()
    return generate
コード例 #6
0
ファイル: run.py プロジェクト: wilsenock220/Password-locker
def generate_password():
    '''
    Generating password automatically
    '''
    create_password = Credential.generate_password()
    return create_password
コード例 #7
0
 def test_generate_password(self):
     '''
     test case to check if the password is generated
     '''
     self.assertTrue(Credential.generate_password())
コード例 #8
0
def generate_password():
    """
	Function to generate a password automatically
	"""
    random_pass = Credential.generate_password()
    return random_pass
コード例 #9
0
def main():

    print("Hello Welcome to your Password Locker. What is your name?")
    user_name = input()
    print(f"Hello {user_name}. What would you like to do?")
    print('\n')

    while True:
        print(
            "Use these short codes:'ca'- create an account, 'li'- login to an account, 'ex'- exit an account"
        )
        short_code = input().lower().strip()

        if short_code == 'ca':
            print("New User")
            print("-" * 30)
            while True:
                print("Enter username ........")
                username = input()

                print("Enter Password.........")
                password = input()
                if username == "" or password == "":
                    print(
                        "username and password required to create an account")
                    continue
                break
            save_user(create_user(username, password))
            print('\n')
            print(
                f"Your account with username:{username} and password:{password} has been created"
            )
            print('\n')

        elif short_code == 'li':

            username = input("Enter your username:  "******"Enter your password:  "******"What would you like to do?")

                while True:
                    print(
                        "Use these shord codes: 'cc'-create a credential, 'dl'-delete a credential, 'fc'-find a credential, 'dc'-display credentials, 'lo' -logout "
                    )
                    short_c_code = input().lower()

                    if short_c_code == 'cc':

                        site_name = input(
                            "Enter the site name for which you want to create a credential: "
                        )

                        while True:
                            account_name = input(
                                "Enter username for the site: ")
                            if (account_name == ""):
                                continue
                            break
                        print(
                            "Do you want to autogenerate password. If yes, press 'Y' else press 'N'"
                        )

                        while True:
                            answer = input().lower()

                            if answer == 'y':
                                accountPassword = Credential.generate_password(
                                )
                                break

                            elif answer == 'n':
                                while True:
                                    print("Enter password of 10 characters: ")
                                    accountPassword = input()

                                    if accountPassword == "" or len(
                                            accountPassword) != 10:
                                        print(
                                            "Invalid Password! Password should be 10 character long:"
                                        )
                                        continue
                                    break
                                break

                            else:
                                print("Unable to understand. Type again")

                        Credential.save_credential(
                            create_credential(username, site_name,
                                              account_name, accountPassword))
                        print(
                            f"Your credential for {site_name} has been saved")

                    elif short_c_code == 'dl':
                        site_name = input(
                            "Enter the site name whose credentials you want to delete: "
                        )
                        if (check_existing_credential(site_name) == False):
                            print("Credentials for this site doesnot exist")
                        else:
                            del_credential(find_credential(site_name))
                            print(
                                f"Credentials for {site_name} has been deleted"
                            )

                    elif short_c_code == 'dc':
                        user_credential_list = display_credentials(username)
                        for credential in user_credential_list:
                            print(
                                f"site name:{credential.site_name} account-name:{credential.account_name} password:{credential.account_password}"
                            )
                            print('\n')
                        user_credential_list = []

                    elif short_c_code == 'lo':
                        print(
                            "Bye! Dont forget to add credentials for a new site!"
                        )
                        break

                    elif short_c_code == 'fc':
                        site_name = input(
                            "Enter the site name whose credentials you want to see: "
                        )
                        if (check_existing_credential(site_name) == False):
                            print("Credentials for this site doesnot exist")
                        else:
                            site_credential = find_credential(site_name)
                            print(
                                f"username for {site_name} is:{site_credential.account_name}"
                            )
                            print(
                                f"password for {site_name} is :{site_credential.account_password}"
                            )

                    else:
                        print('Oops! Wrong option entered. Try again.')

            else:
                print(
                    "No user with this username exist. Please create a new account or exit"
                )

        elif short_code == 'ex':
            break

        else:
            print("-" * 60)
            print(' ')
            print("Oops! Wrong option entered. Try again.")
コード例 #10
0
def generate_password():
    """
    Function to generate a password for new account
    """
    return Credential.generate_password()