xxxxxxxxxx
import secrets
import string
letters = string.ascii_letters
digits = string.digits
special_chars = string.punctuation
alphabet = letters + digits + special_chars
pwd_length = 8
pwd = ''
for i in range(pwd_length):
pwd += ''.join(secrets.choice(alphabet))
print(f'first recommendation is "{pwd}"')
while True:
pwd = ''
for i in range(pwd_length):
pwd += ''.join(secrets.choice(alphabet))
if (any(char in special_chars for char in pwd) and
sum(char in digits for char in pwd) >= 2):
break
print(f'second recommendation is "{pwd}"')
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, string
def generate_password(length: int=4)-> str:
# add lower case chars
lower = [random.choice(string.ascii_lowercase) for i in range(length)]
# add digit chars
digit = [random.choice(string.digits) for i in range(length)]
# add upper case chars
upper = [random.choice(string.ascii_uppercase) for i in range(length)]
# add symbols
symbol = [random.choice(["!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "-", "+", "=", ".", ",", "?"]) for i in range(length)]
# store random generated lists to a variable
original = lower+digit+upper+symbol
# shuffle stored data in place
random.shuffle(original)
return ''.join(original)
xxxxxxxxxx
import secrets
import string
characters = ''
# length
print("=============================================================")
length_input = input("Enter the length of your password (or type 'quit' to exit): ")
if length_input.lower() == 'quit':
exit("Program terminated")
try:
length = int(length_input)
except ValueError:
exit("Invalid input. Please enter a valid number or 'quit' to exit.")
# letters
print("=============================================================")
letters = input("Do you want your password to have letters? (Y/N): ").upper()
if letters == 'QUIT':
exit("Program terminated")
# numbers
print("=============================================================")
numbers = input("Do you want your password to have numbers? (Y/N): ").upper()
if numbers == 'QUIT':
exit("Program terminated")
# symbols
print("=============================================================")
symbols = input("Do you want your password to have symbols? (Y/N): ").upper()
if symbols == 'QUIT':
exit("Program terminated")
if letters == 'Y':
characters += string.ascii_letters
if numbers == 'Y':
characters += string.digits
if symbols == 'Y':
characters += string.punctuation
if characters == '':
print("=============================================================")
print("Your password must contain at least one of the individual types (letters, numbers, symbols)")
# Generate password
generated_password = ''.join(secrets.choice(characters) for _ in range(length))
if generated_password:
print("Generated Password:", generated_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 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
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
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;$