Я заинтересован в создании очень простого, высококачественного (криптографического) генератора случайных паролей. Есть ли лучший способ сделать это?
import os, random, string
length = 13
chars = string.ascii_letters + string.digits + '!@#$%^&*()'
random.seed = (os.urandom(1024))
print ''.join(random.choice(chars) for i in range(length))
"""
This code below in any shape or form is owned by A.S Gallery
This code is the asnwer for Password Generator quiz - CodeHs
This code works 100%
Have fun exploring !!!
"""
# Imports
import random
import time
print "Hi !!!"
password_output = "this is your new password : "
ask_name = input("Enter your Name : ")
greetings_name = "Hi "+ str(ask_name) + "!!! "
print greetings_name
print "Now we will make your new password using the ULTIMATE password generator !!!"
time.sleep(8)
print "Our password generator will give you multiple choices, you can choose any password generator you want !!! "
time.sleep(8)
print "You can choose if you want a strong password or a weak password !! (strong recommended) "
time.sleep(8)
print "You can also make your own password, to make your own password type own !!! "
time.sleep(8)
print "If you want to choose strong type strong, if weak then type weak !!! "
time.sleep(8)
# Example:
# Returns random number within and including 0 and 10.
def strong_password():
user_input = int(input("Enter a number : "))
print type(user_input)
time.sleep(3)
# calculate_input = user_input * user_input
calculate_types = input("Do you want to add, multiply or mod the numbers : ")
time.sleep(3)
if calculate_types == "add":
calculate_input = user_input + user_input
elif calculate_types == "multiply" :
calculate_input = user_input * user_input
elif calculate_types == "mod":
calculate_input = user_input & user_input
else:
print "Check your spelling and try again :( "
# Random element in a string
time.sleep(4)
want_symbols = input("Do you want symbols ?(Y/N) : ")
time.sleep(4)
random_element = random.choice('abcdefg345')
if want_symbols == "Y":
random_element2 = random.choice('@#()@*($*(@)(*^()*()(#$)*@#)*((@*()@*#)(*)@*($*(%#*)#(*@@_!_()(')
elif want_symbols == "N":
random_element2 = random.choice('29371294203712492703740182903820498201381204AKSJFKSHEHJKFJAODL')
random_element3 = random.choice('abcdefghiiasudasdjsiasdhwudagsjdgaskdjsafgjasj')
random_element4 = random.choice('abcdefghijsdhjaskdhkasjdhakdjhaskdasjdhakjsd')
random_element5 = random.choice('abcdefghijsdhsakjdhsajdldasjdasdjasldas')
random_elements6 = random.choice('129389230928308290382109830293943827492347')
random_elements7 = random.choice('2473285473q9mdnuwyr8KSDJKDSJKL932uc3487389473289479h3289wjdi94802w')
random_elements8 = random.choice('AKDJKAJDKJIKJDUIFHSJHUFRUDIJFDKLDJKDJLJFKLJKLDJLDJKLDJLDJLSKJDKLJDLJDKSLJD')
time.sleep(8)
print str(ask_name) + " " + str(password_output) + str(calculate_input) + str(random_element) + str(random_element2) + str(random_element3) + str(random_element4) + str(random_element5) + str(random_elements6) + str(random_elements7) + str(random_elements8)
def weak_password():
user_input = int(input("Enter a number : "))
print type(user_input)
time.sleep(3)
# calculate_input = user_input * user_input
calculate_types = input("Do you want to add, multiply or mod the numbers : ")
time.sleep(3)
if calculate_types == "add":
calculate_input = user_input + user_input
elif calculate_types == "multiply" :
calculate_input = user_input * user_input
elif calculate_types == "mod":
calculate_input = user_input & user_input
else:
time.sleep(3)
print "Check your spelling and try again :( "
# Random element in a string
random_ness = random.choice("ABCDEFGHI*(#*#$()#*$)(E)(UWIJEDSH(*#U$()UDSLKH)UW*)$(*&#*(YE(*DY#*YUHSLDF:LKDDSDK")
my_tuple = (calculate_input, random_ness, user_input, ask_name)
new_tuple = my_tuple[1]
new_tuple1 = my_tuple[2]
new_tuple2 = my_tuple[3]
time.sleep(7)
print str(ask_name) + str(password_output) + str(new_tuple) + str(new_tuple1) + str(new_tuple2)
def own_password():
my_list = []
ask_times = int(input("How many characters do you want ? (between 1 - 8) : "))
time.sleep(10)
if ask_times > 8:
print "Invalid Request"
elif ask_times < 1:
print "Invalid Request"
else:
time.sleep(2)
print "You CANNOT include symbols or numbers in this option !!! "
for i in range(ask_times):
user_ask = input("Enter the character: ")
time.sleep(0.6)
my_list.append(user_ask)
own_password = "".join(map(str,my_list))
time.sleep(4)
print "Your own password is : " + own_password
strong_pass = input("Do you want a strong password or a weak one or make your own password !! ? : ")
if strong_pass == "strong":
strong_password()
elif strong_pass == "weak":
weak_password()
elif strong_pass == "own":
own_password()
else :
print "Invalid Request"
time.sleep(3)
print "Congrats, on creating your best password !!! I belived you used strong password generator because its the BEST !!"
time.sleep(7)
print "If not, no problem just restart the program and type strong when prompted !!! "
time.sleep(6)
print "Have a nice day !"
Этот код является ответом для Теста CodeHs также (если у Вас был кто-либо)!!!