Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import random
  2. alfabet_lower='qwertyuiopasdfghjklzxcvbnm'
  3. alfabet_Upper=alfabet_lower.upper()
  4. numbers='1234567890'
  5. spec_chars=">!'^+%&/()=?_-*,.:;<|>£#$½§{[]}\|≥≤µ~∫√≈Ωæ´¨∆^ğƒ∂ßæ~¨¥₺®€∑@`"
  6. A_list=list(alfabet_Upper)
  7. a_list=list(alfabet_lower)
  8. n_list=list(numbers)
  9. s_c_list=list(spec_chars)
  10.  
  11. All_list=A_list + a_list + n_list + s_c_list
  12.  
  13. 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()
  14. weak_password_text_list=list(set(weak_password_text.split()))
  15.  
  16.  
  17. def strong_password_gen(long):
  18. if int(long) < 8:
  19. return 'not enough long for a strong password'
  20. else:
  21. x=[]
  22. for i in range(int(long)):
  23. r=random.randint(0,len(All_list)-1)
  24. x.append(All_list[r])
  25. return ''.join(x)
  26.  
  27. def weak_password_gen(): #generates weak password with one word with longer than 8 or two word
  28. r1=random.randint(0,len(weak_password_text_list)-1)
  29. r2 = random.randint(0, len(weak_password_text_list) - 1)
  30. if len(weak_password_text_list[r1]) >= 8:
  31. return weak_password_text_list[r1]
  32. else:
  33. return str(weak_password_text_list[r1]) + str(weak_password_text_list[r2])
  34.  
  35. ask=input('you want a week password or strong? please type ')
  36. if ask == 'strong':
  37. lonG = input('please input the long of the password above 8 ')
  38. print(strong_password_gen(lonG))
  39. elif ask == 'weak':
  40. print(weak_password_gen())
  41. else:
  42. print('you did not type weak or strong')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement