Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rileyrichard committed Mar 24, 2024
1 parent d0bad99 commit 952f0bc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 13 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Mango

## Changelog

### Version 1.0

- Added basic functionality including basic random.randint password generation

### Version 1.1

- Improved on the functionality, adding Tkinter support with a GUI
59 changes: 46 additions & 13 deletions Mango.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import random
import os
import tkinter
from tkinter import *
from tkinter.ttk import *

'''
A password generator written in Python developed by
Expand All @@ -10,16 +14,45 @@
This will use Python's random number generator as well as ASCII to generate a random password
'''
def userInput():
print("Welcome to the Password Generator")
numChars = input("Please enter the number of characters for your password.\n> ")
return int(numChars)

def generatePassword(numberOfCharacters):
password = [None] * numberOfCharacters
for index, values in enumerate(password):
passwordNum = random.randint(65,122)
passwordChar = chr(passwordNum)
password[index] = passwordChar
return ''.join(password)
print(generatePassword(userInput()))
def generatePassword():
completedPassword.configure(state='normal')
completedPassword.delete(1.0,'end')
if userInput.get() == "":
completedPassword.insert(1.0,"Please enter a number")
else:
numberOfCharacters = int(userInput.get())
if numberOfCharacters > 7 and numberOfCharacters < 33:
password = [None] * numberOfCharacters
for index, values in enumerate(password):
passwordNum = random.randint(65,122)
passwordChar = chr(passwordNum)
password[index] = passwordChar
completedPassword.insert(1.0,''.join(password))
else:
completedPassword.insert(1.0,'Please enter a valid number 8-32')
completedPassword.configure(state='disabled')


rootWindow = tkinter.Tk() # Root level window
rootWindow.geometry("275x250") # Root Window dimensions
rootWindow.title("Mango") # Sets the title of the window

userInput = tkinter.StringVar() # Sets the user input


'''
Labels, Text and Buttons
'''
characterLimit = Label(rootWindow, text="Character Limit (8-32 Chars)")
userInputEntry = Entry(rootWindow, textvariable=userInput, font=('arial',10))
refreshButton = Button(rootWindow, text="Refresh Password",command=generatePassword)
completedPassword = Text(rootWindow, height=1,width=32)

characterLimit.grid(row=1,column=0, sticky='w')
userInputEntry.grid(row=2,column=0, sticky='w')
refreshButton.grid(row=3,column=0, sticky='w')
completedPassword.grid(row=4,column=0, sticky='w')


# The main loop for displaying the tkinter window
rootWindow.mainloop()

0 comments on commit 952f0bc

Please sign in to comment.