Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import string
- import re
- def validate_password(password):
- with open("ordlista_sv.txt", "r") as wl:
- wordlist = wl.readlines()
- wl.close()
- wordlist = [x[:-1] for x in wordlist]
- if len(password) >= 8:
- if password not in wordlist:
- if re.search('[a-z]', password) and re.search('[A-Z]', password) \
- and re.search('[0-9]', password) and re.search(r"[!\"#$%&'()*+,\-./:;<=>?@\[\]^_`{|}~]", password):
- print(password, "is valid")
- return True
- else:
- print(password, "is invalid")
- return False
- def generate():
- valid = False
- while not valid:
- password = string.ascii_letters + string.digits + string.punctuation
- password = "".join(random.choice(password) for i in range(10))
- digits = 0
- valid = validate_password(password)
- if valid:
- return password
- generate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement