What would be some improvements you would make to this password generator? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

What would be some improvements you would make to this password generator?

"""Before you start I should mention that I also have other codes that go with this, and a picture inserted in the top of the GUI. You obviously won't get that here with only the GUI portion of the code""" from tkinter import * import string import secrets # use to copy our generated pw to clipboard import pyperclip # for generating random pw import random from tkinter import ttk # initializing tkinter root = Tk() # Set icon photo photo = PhotoImage(file=r'C:\Users\joseph.bonfantijr_sc\Desktop\Python\PWGen\Junior.png') root.iconphoto(False, photo) # set title root.title('PW Gen - Joe') # setting the width and height of the gui root.geometry("500x300") # x small case here # declaring variable of str type. Variable will be used to store pw generated passstr = StringVar() # declaring variable of int type which will be used to store length of pw entered by user passlen = IntVar() # setting the length of pw to zero passlen.set(0) # progress bar for executing pw progress = ttk.Progressbar(root, orient = HORIZONTAL, length = 100, mode = 'determinate') progress.pack() # function to copy password to clipboard def copytoclipboard(): random_password = passstr.get() pyperclip.copy(random_password) # disable copy button until pw generated copy_button = Button(root, text="Copy to clipboard", command=copytoclipboard, state='disabled') # validate pw is correct length def validate_password_length(P): P = str(passlen.get()) if not P.isdigit(): return False elif int(P) < 4 or int(P) > 30: return False else: return True # function to generate password def generate(): if not validate_password_length(passlen.get()): return characters = string.ascii_letters + string.digits + string.punctuation password = "" progress["value"] = 0 progress["maximum"] = passlen.get() for i in range(passlen.get()): password += secrets.choice(characters) progress["value"] += 1 progress.update() passstr.set(password)

6th Feb 2023, 7:41 PM
IAmJunior B
IAmJunior B - avatar
5 Antworten
+ 1
Here are some improvements that can be made to the password generator: 1) GUI improvement: The GUI can be made more user-friendly, for example by making the size of the text field for entering the password length more prominent or by providing a clear message to the user if the password length is not in the correct range. 2) Add a password strength meter: The program can check the strength of the generated password and indicate to the user if it is weak, medium, or strong. 3) Add a password policy: The program can enforce a password policy, such as requiring a minimum number of upper case letters, lower case letters, digits, and special characters. 4) Use more secure random number generation: Currently, the program uses the Python built-in random module, but it can be improved by using a more secure random number generator like the "secrets" module. 5) Error handling: The program can include error handling to provide more informative error messages in case of any errors.
6th Feb 2023, 8:13 PM
ArsenicolupinIII
+ 1
Split generations into to functions, called generations_error, and generations why? I see you handling errors in generations and valid input functions Use itertools for some more customization generations Use a yield for loop mostly everything you wrote is static and not reusable. if u also want to see how to create pw gen you can see my crack-it code on my profile here an improved example https://code.sololearn.com/cuOq7q8q9ENi/?ref=app
6th Feb 2023, 8:37 PM
Ion Kare
Ion Kare - avatar
0
6) Save password to a file: The program can give the option to save the generated password to a file. 7) Customize the password character set: The program can provide the option for the user to choose what characters to include in the password (e.g., letters, digits, punctuation, etc.). I hope this information has been helpful to you.
6th Feb 2023, 8:13 PM
ArsenicolupinIII
0
Thanks ArsenicolupinIII i will check these out.
6th Feb 2023, 8:15 PM
IAmJunior B
IAmJunior B - avatar
0
let me know if these steps work. :)
6th Feb 2023, 8:17 PM
ArsenicolupinIII