diff --git a/gen_pass.py b/gen_pass.py index c531b75..bdc5a87 100644 --- a/gen_pass.py +++ b/gen_pass.py @@ -1,16 +1,29 @@ #!/usr/bin/env python3 import string import random +from pathlib import Path MAX_WORD_LEN = 10 MIN_WORD_LEN = 6 +WORDLIST_PATH = Path(__file__).parent / "wordlists/words_alpha.txt" -def gen_pass(dict_file="wordlists/words_alpha.txt"): +def check_repeating_chars(word): + last_char = None + for c in word: + if c == last_char: + return True + else: + last_char = c + + return False + +def gen_pass(dict_file=WORDLIST_PATH): 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): + if (not (MIN_WORD_LEN <= len(lines[i]) <= MAX_WORD_LEN) + or check_repeating_chars(lines[i])): continue wordlist.append(lines[i][0].upper() + lines[i][1:])