Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,55 @@
#
import random
import string

# Define character sets
lower = string.ascii_lowercase
uppper = string.ascii_uppercase
print(uppper)
print(string.ascii_letters)
upper = string.ascii_uppercase
symbols = "!@#$%^&*()-+[]{}"
numbers = "0123456789"
all = lower + uppper + symbols + numbers
all = lower + upper + symbols + numbers

# Print character sets for reference
print(upper)
print(string.ascii_letters)

while True:
print("choose an option :\n\t1) create a password\n\t2) exit")
choise = input("your choice : ")
if choise == "1":
length = int(input("enter the password length : "))
password = "".join(random.sample(all, length))
print(password)
elif choise == "2":
print("Choose an option: \n\t1) Create a password\n\t2) Exit")
choice = input("Your choice: ")

if choice == "1":
social_media = input("For which social media do you want this password? : 1.instagram/facebook | 2.tonkeeper | 3.email | 4.X | 5.other :")

if social_media == "1":
password = "".join(random.sample(all, 6))
print(f"Generated password: {password}")
elif social_media == "2":
password = "".join(random.sample(numbers, 4))
print(f"Generated password: {password}")
elif social_media == "3":
password = "".join(random.sample(all, 15))
print(f"Generated password: {password}")
elif social_media == "4":
password = "".join(random.sample(all, 10))
print(f"Generated password: {password}")
elif social_media == "5":
password = "".join(random.sample(all, 12))
print(f"Generated password: {password}")
else:
print("Invalid option for social media choice.")

# Save the password to a file
try:
with open("passwords.txt", "a") as file:
file.write(f"{social_media}: {password}\n")

# Read and print the contents of the file
with open("passwords.txt", "r") as file:
print("\nSaved Passwords:")
print(file.read())
except Exception:
print(f"An error occurred: {e}")

elif choice == "2":
break
else:
print("invalid option")
print("Invalid option")