35 lines
843 B
Python
35 lines
843 B
Python
#!/usr/bin/env python3
|
|
import string
|
|
import random
|
|
|
|
MAX_WORD_LEN = 10
|
|
MIN_WORD_LEN = 6
|
|
|
|
def gen_pass(dict_file="wordlists/words_alpha.txt"):
|
|
wordlist = []
|
|
with open(dict_file, 'r') as f:
|
|
lines = f.read().splitlines()
|
|
for i in range(len(lines)):
|
|
if not (MIN_WORD_LEN <= len(lines[i]) <= MAX_WORD_LEN):
|
|
continue
|
|
|
|
wordlist.append(lines[i][0].upper() + lines[i][1:])
|
|
|
|
other_chars = [string.punctuation, string.digits, string.digits]
|
|
random.shuffle(other_chars)
|
|
|
|
return (
|
|
random.choice(wordlist) +
|
|
random.choice(other_chars[0]) +
|
|
random.choice(wordlist) +
|
|
random.choice(other_chars[1]) +
|
|
random.choice(wordlist) +
|
|
random.choice(other_chars[2])
|
|
)
|
|
|
|
def main():
|
|
print(gen_pass())
|
|
|
|
if __name__ == '__main__':
|
|
main()
|