improves random word generation
- only words matching a-zA-Z are used, which removes some situations where the generated code was not readable by the android application - words are now under 10 characters long - function flow improved for readability
This commit is contained in:
parent
1e7301d919
commit
570a64f450
13
bump/bump.py
13
bump/bump.py
@ -76,12 +76,17 @@ class Bump:
|
||||
return secrets
|
||||
|
||||
def generate_secret(self, secrets_file):
|
||||
pattern = re.compile('^[a-zA-Z]+$')
|
||||
WORDS = r.get_random_words()
|
||||
secret = ""
|
||||
for _ in range(SENDER_LENGTH + PASSWORD_LENGTH):
|
||||
secret += random.choice(WORDS) + "-"
|
||||
while len(secret[SENDER_LENGTH:]) < 32:
|
||||
secret += random.choice(WORDS) + "-"
|
||||
word_count = 0
|
||||
while word_count < SENDER_LENGTH + PASSWORD_LENGTH or len(secret[SENDER_LENGTH:]) < 32:
|
||||
word = random.choice(WORDS)
|
||||
print(pattern.match(word))
|
||||
if pattern.match(word) and len(word) < 10:
|
||||
secret += word + "-"
|
||||
word_count += 1
|
||||
|
||||
secret = secret[:-1]
|
||||
|
||||
self.secrets.append(secret)
|
||||
|
Loading…
Reference in New Issue
Block a user