From 826f38a05424e5bc5d1286e4041688734fe1b6a5 Mon Sep 17 00:00:00 2001 From: Random936 Date: Sun, 7 Jul 2024 16:21:03 -0700 Subject: [PATCH] Removed repeating characters and made wordlist path relative to script location --- gen_pass.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) 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:])