Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- alfabet_lower='qwertyuiopasdfghjklzxcvbnm'
- alfabet_Upper=alfabet_lower.upper()
- numbers='1234567890'
- spec_chars=">!'^+%&/()=?_-*,.:;<|>£#$½§{[]}\|≥≤µ~∫√≈Ωæ´¨∆^ğƒ∂ßæ~¨¥₺®€∑@`"
- A_list=list(alfabet_Upper)
- a_list=list(alfabet_lower)
- n_list=list(numbers)
- s_c_list=list(spec_chars)
- All_list=A_list + a_list + n_list + s_c_list
- weak_password_text='Write a password generator in Python. Be creative with how you generate passwords strong passwords have a mix of lowercase letters uppercase letters numbers and symbols The passwords should be random generating a new password every time the user asks for a new password Include your runtime code in a main method'.upper()
- weak_password_text_list=list(set(weak_password_text.split()))
- def strong_password_gen(long):
- if int(long) < 8:
- return 'not enough long for a strong password'
- else:
- x=[]
- for i in range(int(long)):
- r=random.randint(0,len(All_list)-1)
- x.append(All_list[r])
- return ''.join(x)
- def weak_password_gen(): #generates weak password with one word with longer than 8 or two word
- r1=random.randint(0,len(weak_password_text_list)-1)
- r2 = random.randint(0, len(weak_password_text_list) - 1)
- if len(weak_password_text_list[r1]) >= 8:
- return weak_password_text_list[r1]
- else:
- return str(weak_password_text_list[r1]) + str(weak_password_text_list[r2])
- ask=input('you want a week password or strong? please type ')
- if ask == 'strong':
- lonG = input('please input the long of the password above 8 ')
- print(strong_password_gen(lonG))
- elif ask == 'weak':
- print(weak_password_gen())
- else:
- print('you did not type weak or strong')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement