Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import string
- import secrets
- def choose_alphabet(alphabet_types):
- alphabets = {
- 'latin_uppercase': string.ascii_uppercase,
- 'latin_lowercase': string.ascii_lowercase,
- 'russian_uppercase': 'АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ',
- 'russian_lowercase': 'абвгдежзийклмнопрстуфхцчшщъыьэюя',
- 'symbols': string.punctuation,
- 'digits': string.digits,
- }
- chosen_alphabet = ''
- for alphabet_type in alphabet_types:
- alphabet = alphabets.get(alphabet_type)
- if alphabet:
- chosen_alphabet += alphabet
- return chosen_alphabet, len(chosen_alphabet)
- def generate_password(length, alphabet):
- password = ''.join(secrets.choice(alphabet) for _ in range(length))
- return password
- P = 10e-7
- V = 10
- T = 30240
- S1 = math.ceil(V * T / P) # нижняя граница
- alphabet, A = choose_alphabet(["latin_uppercase", "symbols"])
- L = 0
- while not (S1 <= A ** L):
- L += 1
- print("S* =", S1)
- print("A =", A)
- print("L =", L)
- print("password:", generate_password(L, alphabet))
Advertisement
Add Comment
Please, Sign In to add comment