Esempio n. 1
0
    def new_password(self):
        """Creates a new password

        Returns: A new password
        """
        # create new password
        return password_generator.create_password()
Esempio n. 2
0
def gen_login():
    user_name = input("Please enter your username")
    log.info("User name is inputted by user to system. User : {}".format(user_name))
    if user_name in users:
        log.debug("Checking if user name has been used before")
        print("That username is already taken, please try again")
        log.info("Username is taken so they need to retry")
        gen_login()
    else:
        users.append(user_name)
        log.debug("Adding the user to the database.")
        want_password = input("Do you want us to generate a password for you, yes or no?")
        log.debug("Asking if the user wants a auto-generated password.")
        if want_password == "yes":
            password = pg.create_password()
            print(password)
            print("Your password is {}".format(password))
            log.info("The password as been autogenerated to: {}.".format(password))
        else:
            password = input("Please enter your password")
            print("Your password is {}".format(password))
            log.info("User decided to create their own password")
        passwords.append(password)
    print("Thank you for registering, your username is: ({}) and your password is: ({})!".format(user_name, password))
Esempio n. 3
0
from controller import Controller
from password_generator import create_password

if __name__ == "__main__":
    new_password = create_password()

    # Use screen scraper to change password

    test = Controller(["*****@*****.**"], 'test_password')
    test.run()

    # Email_Handler = Email_Handler(["*****@*****.**"])
    # Email_Handler.send("Your new password is: " + new_password)

# TODO: create main program flow and lifecycle here
Esempio n. 4
0
def call_password():
    password_entry.delete(0, 'end')
    new_password = create_password()
    password_entry.insert(0, new_password)
    pyperclip.copy(new_password)
Esempio n. 5
0
def execute():
    #CHARSET SELECTION
    print(">> Charset available: ");
    print(">> 1 - ",charset_0);
    print(">> 2 - ",charset_1);
    print(">> 3 - ",charset_2);
    print(">> 4 - ",charset_3);
    selection = str(input(">> Select charset [1-4]: "));
    if(selection == '1'):
        charset = charset_0;
    elif(selection == '2'):
        charset = charset_1;
    elif(selection == '3'):
        charset = charset_2;
    elif (selection == '4'):
        charset = charset_3;
    else:
        print(">> Invalid choice. Default (1) will be used");
        charset = charset_0;
    # LENGTH SELECTION
    try:
        length_password = int(input(">> Set password length [6-128]: "));
        if(length_password > 128):
            print(">> Maximum password length reached. Length password will be 128");
            length_password = 128;
        if(length_password < 6):
            print(">> Minimum password length not reached. Length password will be 6");
            length_password = 6;
    # IF THERE'S ANY ERROR (NEGATIVE NUMBER, LETTERS) JUST PUT A LENGTH OF 16
    except:
        print(">> Incorrect input. Length is set to 16");
        length_password = 16;
    # FILE SECTION
    pass_text_num = str(input(">> Would you like to write passwords and encrypted password in the same file?[y/n]: "));
    print(">> Select the file exported from your browser:\n ");
    try:
        path_plus_filename = askopenfilename();
        while(Path(path_plus_filename).suffix != '.csv'):
            print(">> File selected is not a csv. Retry...");
            path_plus_filename = askopenfilename();
        path = os.path.dirname(path_plus_filename);
        filename = os.path.basename(path_plus_filename);
        if(os.name == "nt"):
            path = path + "\\";
        elif(os.name == "posix"):
            path = path + "/";
        # IF NOTHING IS SELECTED, WE CAN'T ACCESS THE FOLDER OR ANYTHING ELSE
        # PUT THE FILES ON THE DESKTOP
    except:
        print(">> No file selected. Program will now exit");
        sys.exit(0);
    print(">> File(s) will be created in " + path);

    # CHECK IF THE FILES ARE ALREADY THERE
    # IF SO, WE DELETE THEM

    if(pass_text_num == 'y' or pass_text_num == 'Y'):
        if (os.path.isfile(path + "list_clear_and_encrypted_passwords.csv") == 'True'):
            os.remove(path + "list_clear_and_encrypted_passwords.csv");
        num_files = 1;
    elif(pass_text_num == 'n' or pass_text_num == 'N'):
        if (os.path.isfile(path + "list_clear_passwords_new.csv") == 'True'):
            os.remove(path + "list_clear_passwords_new.csv");
        if (os.path.isfile(path + 'list_encrypted_passwords_new.csv') == 'True'):
            os.remove(path + 'list_encrypted_passwords_new.csv');
        num_files = 2;
    else: # INVALID CHOICE --> CHOOSE TO USE 2 FILE
        print(">> Choice not valid. Two files will be created");
        if (os.path.isfile(path + "list_clear_passwords_new.csv") == 'True'):
            os.remove(path + "list_clear_passwords_new.csv");
        if (os.path.isfile(path + 'list_encrypted_passwords_new.csv') == 'True'):
            os.remove(path + 'list_encrypted_passwords_new.csv');
        num_files = 2;

    # EXECUTION WITH ONLY ONE FILE
    if(num_files == 1):
        with open(path + 'list_clear_and_encrypted_passwords.csv',mode = 'w',newline = "\n") as list_clear_encrypted_passwords:
            clear_encrypted_writer = csv.writer(list_clear_encrypted_passwords,delimiter = ";")
            clear_encrypted_writer.writerow(["SITE","USERNAME","PASSWORD","ENCRYPTED PASSWORD"]);
            with open(path_plus_filename,mode = 'r') as chrome_exported_passwords:
                for i,row in enumerate(chrome_exported_passwords.readlines()):
                    if(i == 0): # SKIP 'SITE','USERNAME',[...], ROW
                        pass;
                    else:
                        try:
                            items = row.split(',');
                            site_name = items[0];
                            user_name = items[1];
                            password = password_generator.create_password(length_password, charset);
                            caesar_password = caesar_cipher.execute(password);
                            clear_encrypted_writer.writerow([site_name,user_name,password,caesar_password,]);
                        except:
                            items = row.split(';');
                            site_name = items[0];
                            user_name = items[1];
                            password = password_generator.create_password(length_password, charset);
                            caesar_password = caesar_cipher.execute(password);
                            clear_encrypted_writer.writerow([site_name,user_name,password,caesar_password,]);
    # EXECUTION WITH TWO FILES
    else:
        #
        # NOTE:
        # I had to write the file with the clear passwords and after that the one
        # with the encrypted password because .csv files can't be processed as
        # normal text file (as far as I know);
        # So, I'll write the first file, and then use it to create the second
        #

        # NOW WE CREATE THE NEW FILE CONTAINING ALL THE NEW (CLEAR) PASSWORDS
        with open(path + 'list_clear_passwords.csv',mode = 'w',newline = "\n") as list_clear_passwords:
            clear_writer = csv.writer(list_clear_passwords,delimiter = ";")
            clear_writer.writerow(["SITE","USERNAME","PASSWORD"]);
            with open(path_plus_filename,mode = 'r') as chrome_exported_passwords:
                for i,row in enumerate(chrome_exported_passwords.readlines()):
                    if(i == 0): # SKIP 'SITE','USERNAME',[...], ROW
                        pass;
                    else:
                        try:
                            items = row.split(',');
                            site_name = items[0];
                            user_name = items[1];
                            password = password_generator.create_password(length_password, charset);
                            clear_writer.writerow([site_name,user_name,password,]);
                        except:
                            items = row.split(';');
                            site_name = items[0];
                            user_name = items[1];
                            password = password_generator.create_password(length_password, charset);
                            clear_writer.writerow([site_name,user_name,password,]);
        # NOW WE CREATE THE NEW FILE CONTAINING ALL THE NEW (encrypted) PASSWORDS
        with open(path + 'list_encrypted_passwords.csv',mode = 'w',newline = "\n") as list_encrypted_passwords:
            encrypted_writer = csv.writer(list_encrypted_passwords,delimiter = ";")
            encrypted_writer.writerow(["SITE","USERNAME","ENCRYPTED PASSWORD"]);
            with open(path + 'list_clear_passwords.csv',mode = 'r') as new_exported_passwords:
                for i,row in enumerate(new_exported_passwords.readlines()):
                    if(i == 0): # SKIP 'SITE','USERNAME',[...], ROW
                        pass;
                    else:
                        items = row.split(';');
                        site_name = items[0];
                        user_name = items[1];
                        password = items[2][:-1]; # password contains also "\n" at the end
                                                  # we don't want to count it
                        caesar_password = caesar_cipher.execute(password);
                        encrypted_writer.writerow([site_name,user_name,caesar_password,]);
    # WE'RE DONE
    print("\n");
    print(">> Please check if there are any errors in the new files");
    print(">> (Like repeated passwords, presence of some old passwords etc.)");
    print(">> [Thank you for your comprehension]\n");
    print(">> Program terminated. Remember: your file(s) are stored in ",path);
Esempio n. 6
0
    while show_menu:
        #Code Here
        service_choice = input('''Choose your service
        1-Phone number generator
        2-Password generator
        3-Check password

        to quit : press q
        \n''')

        if service_choice == '1':
            operator_choice = input('''Choose your operator:
                                    1-irancell
                                    2-HamraheAval''')
            phone_number = create_phone_number(operator=operator_choice)
            print(f"Your suggested phone number :{phone_number}\n")

        elif service_choice == '2':
            password_type = password_type()
            password_generated = create_password(**password_type)
            print(f"your password generated : {password_generated}\n")

        elif service_choice == '3':
            user_password = input('enter your password\n')
            password_strength = recognize_password_strength(user_password)
            print(password_strength)

        elif service_choice == 'q':
            print('see you!')
            show_menu = False