mardi 30 novembre 2021

is there a simpler way to generate random password [duplicate]

import string
import random
characters = list(string.ascii_letters + string.digits + "!@#$%^&*()")

i = input('Please enter confirm (input 1) to proceed with password creation (or any to quit):\n')
if i == 1:
  print("Generating username and password....") 
  length = int(input("Enter password length: "))
  random.shuffle(characters)


  password = []
  for i in range(length):
    password.append(random.choice(characters))


  random.shuffle(password)



  print("".join(password))

else:
   exit

Is there a simpler way to generate a random password, also generating a password doesn't work in the if statement how do i fix this. I also want to be able to call out my password so how do i put it in a variable after ive generated one.

Aucun commentaire:

Enregistrer un commentaire