Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import string
  2. import random
  3. from random_word import RandomWords
  4. rw = RandomWords()
  5.  
  6. def generate_pwd(length, slvl):
  7. if slvl == 1:
  8. pwd = rw.get_random_word(minLength=length)
  9. elif slvl == 2:
  10. temp = string.ascii_letters + string.digits
  11. pwd = ''.join(random.choice(temp) for i in range(length))
  12. elif slvl == 3:
  13. temp = string.ascii_letters + string.digits + string.punctuation
  14. pwd = ''.join(random.choice(temp) for i in range(length))
  15. else:
  16. exit('Invalid input given for strength')
  17. return pwd
  18.  
  19. print('''Choose Strength of your password:
  20. 1 : Weak
  21. 2 : Medium
  22. 3 : Strong :''')
  23. slvl = int(input())
  24. length = int(input('Enter length of password: '))
  25. if length > 15 or length < 6:
  26. length = random.randint(6, 15)
  27. print('\nLength is either too short or larger than 15\nHence using random value: ',length)
  28. else:
  29. pass
  30.  
  31. print('Genrated password : '+ generate_pwd(length, slvl))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement