Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def get_char():
- return random.choice(characters)
- def print_password(password):
- print("auto-generated password is:")
- print(password)
- def set_password(strength):
- password = ""
- if strength == "1":
- for i in range(6):
- password += get_char()
- return password
- elif strength == "2":
- for i in range(10):
- password += get_char()
- return password
- elif strength == "3":
- for i in range(14):
- password += get_char()
- return password
- elif strength == "4":
- for i in range(20):
- password += get_char()
- return password
- characters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', '@', '#', '$', '%', '&', '*', '(', ')']
- strength = input("Enter strength: 1 for weak - 2 for medium - 3 for strong - 4 for extra strong: ")
- password = set_password(strength)
- print_password(password)
- print("now i will try to break your password")
- n = len(characters)
- m = len(password)
- found = ""
- j=0
- i=0
- while i < n:
- deneme = characters[i]
- while j < m:
- if deneme == password[j]:
- found += deneme
- j += 1
- i = 0
- print(found)
- break
- else:
- i += 1
- break
- if found == password:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement