Skip to content

Latest commit

 

History

History
43 lines (26 loc) · 2.95 KB

File metadata and controls

43 lines (26 loc) · 2.95 KB

Password Manager with generator

Table of Contents
  1. Password Generator: File
  2. Password Generator GUI: File

Password Generator

This file defines a function called passwordGen which generates a random password based on the provided parameters. There are 5 parameters available:

  • length: Specifies the length of the password to be generated. The remaining parameters
  • uppercase
  • lowercase
  • numbers
  • symbols specify whether or not each corresponding character set should be included in the final password.

The code first initiates an empty string named characters to hold the characters that will be used in the password. Then, based on the parameters passed in, the corresponding character sets are added to the charcters string using Python's string module.

Finally, using the secrets module of Python, the password variable is generated by selecting random characters from the characters string for length number of times. It then returns the randomly generated password.

Password Generator GUI

This code creates a graphical user interface (GUI) for a password generator. The GUI has input fields for the password length and checkboxes for selecting different types of characters. Users can select the character types they want to include in their password and generate a password by clicking on the "Generate Password" button. The password is then displayed in a label, and users can copy it to the clipboard by clicking on the "Copy" button.

The code uses Python's string, secrets, pyperclip and tkinter modules to generate the password, copy it to clipboard and generate the GUI.

The GUI is defined as a class called PasswordGeneratorGUI that inherits from the tk.frame class. In the constructor, the title of the GUI window is set and the layout grid is defined using the grid() method.

The createWidgets() method creates the UI elements, including a label and entry for setting the password length, checkbuttons for selecting character types, a button for generating the password, a label for displaying the generated password, and a button for copying the generated password to the clipboard.

The generatePassword() method is called when the "Generate Password" button is clicked. It gets the selected password length and character types from the UI elements, generates a random password using the secrets library, and displays the password in the UI.

The copyPassword() method is called when the "Copy" button is clicked. It retrieves the generated password from the UI and uses the pyperclip library to copy the password to the clipboard.

The main section of the code creates the tkinter root window and sets its size and position on the screen. An instance of the PasswordGeneratorGUI class is created and the mainloop() method is called to start the GUI event loop.