xxxxxxxxxx
import string
import random
## characters to generate password from
characters = list(string.ascii_letters + string.digits + "!@#$%^&*()")
def generate_random_password():
## length of password from the user
length = int(input("Enter password length: "))
## shuffling the characters
random.shuffle(characters)
## picking random characters from the list
password = []
for i in range(length):
password.append(random.choice(characters))
## shuffling the resultant password
random.shuffle(password)
## converting the list to string
## printing the list
print("".join(password))
## invoking the function
generate_random_password()
xxxxxxxxxx
import random
lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
symbols = "@#$&_-()=%*:/!?+."
string = lower + upper + numbers + symbols
length = int(input("How Many Characters Do You Want Your Password To Be: "))
password = "".join(random.sample(string, length))
print("Here Is Your Password:", password)
xxxxxxxxxx
import random
print("\n")
def greeting():
print("PASSWORD GENERATOR\n")
greeting()
def passwordgen():
print("\n")
lower_case="abcdefghijklmnopqrstuvwxyz"
upper_case="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
number="0123456789"
symbols="!@#$%^&*()_+:"
jap="あいうえおかきくけこさしすせそなにぬねのたちつてとはひふへほまみむめもらりるれろやゆよ"
Use_for=lower_case+upper_case+number+symbols+jap
length_for_password=10
password="".join(random.sample(Use_for, length_for_password))
print("Your generated password is "+password)
passwordgen()
xxxxxxxxxx
import random
strong_keys = ["@","#","$","£","π","¥","&","3","¢","3","*","?","!","%","/","G","A","B","F","W","F","H","6","9",":","^","=","|","~","∆"]
def password():
try:
n = int(input('your password contain(type in number) : '))
except:
print('type in number please')
password()
ans = ""
for i in range(n):
rand = random.choice(strong_keys)
if i == 0:
ans = rand
else:
ans += rand
print('\n\nyour password: '+ans+'\n\n')
user = input('if you dont like this?\nType \"r\" else \"q\" : ')
if user.lower() == 'r':
password()
else:
quit()
password()
xxxxxxxxxx
import random
lower_case = "abcdefghijklmnopqrstuvwxyz"
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
symbols = "!#$%&()*+,-./:;<=>?@[\]^_`{|}~"
allChars = lower_case + upper_case + numbers + symbols
length = 10
password = "".join(random.sample(allChars, length))
print(password)
xxxxxxxxxx
import string
import random
## characters to generate password from
alphabets = list(string.ascii_letters)
digits = list(string.digits)
special_characters = list("!@#$%^&*()")
characters = list(string.ascii_letters + string.digits + "!@#$%^&*()")
def generate_random_password():
## length of password from the user
length = int(input("Enter password length: "))
## number of character types
alphabets_count = int(input("Enter alphabets count in password: "))
digits_count = int(input("Enter digits count in password: "))
special_characters_count = int(input("Enter special characters count in password: "))
characters_count = alphabets_count + digits_count + special_characters_count
## check the total length with characters sum count
## print not valid if the sum is greater than length
if characters_count > length:
print("Characters total count is greater than the password length")
return
## initializing the password
password = []
## picking random alphabets
for i in range(alphabets_count):
password.append(random.choice(alphabets))
## picking random digits
for i in range(digits_count):
password.append(random.choice(digits))
## picking random alphabets
for i in range(special_characters_count):
password.append(random.choice(special_characters))
## if the total characters count is less than the password length
## add random characters to make it equal to the length
if characters_count < length:
random.shuffle(characters)
for i in range(length - characters_count):
password.append(random.choice(characters))
## shuffling the resultant password
random.shuffle(password)
## converting the list to string
## printing the list
print("".join(password))
## invoking the function
generate_random_password()
xxxxxxxxxx
import string
import random
chars = list(string.ascii_letters + string.digits)
lenght = int(input("Lenght: "))
password = []
random.shuffle(chars)
for i in range(lenght):
random.shuffle(chars)
password.append(random.choice(chars))
print("".join(password))
xxxxxxxxxx
import random
import string
def generate_password(length):
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random.choice(characters) for _ in range(length))
return password
password_length = 10 # Specify the desired password length
generated_password = generate_password(password_length)
print(generated_password)
xxxxxxxxxx
from random import randint
def create_random_chars(nbr_of_chars):
return "".join(chr(randint(33,126)) for i in range(nbr_of_chars))
print(create_random_chars(10))
# I1CU>E5q;$
xxxxxxxxxx
import random
import string
def generate_password(length):
characters = string.ascii_letters + string.digits + string.punctuation
password = ''.join(random.choice(characters) for _ in range(length))
return password
# Example usage for a password of length 20
password = generate_password(20)
print(password)