Removed repeating characters and made wordlist path relative to script location

This commit is contained in:
Random936 2024-07-07 16:21:03 -07:00
parent 041360fef1
commit 826f38a054

View File

@ -1,16 +1,29 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import string import string
import random import random
from pathlib import Path
MAX_WORD_LEN = 10 MAX_WORD_LEN = 10
MIN_WORD_LEN = 6 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 = [] wordlist = []
with open(dict_file, 'r') as f: with open(dict_file, 'r') as f:
lines = f.read().splitlines() lines = f.read().splitlines()
for i in range(len(lines)): 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 continue
wordlist.append(lines[i][0].upper() + lines[i][1:]) wordlist.append(lines[i][0].upper() + lines[i][1:])