Update app.py
Browse files
app.py
CHANGED
|
@@ -59,19 +59,16 @@ helper_words = {
|
|
| 59 |
}
|
| 60 |
|
| 61 |
def generate_helper_phrase(ciphertext, cipher_map):
|
| 62 |
-
# Generate a helper phrase using
|
| 63 |
helper_phrase = []
|
| 64 |
-
desired_length = 3 * len(ciphertext) # Desired length for the helper phrase
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
word = random.choice(helper_words[letter.upper()])
|
| 70 |
# Encrypt the helper word using the same cipher map
|
| 71 |
encrypted_word = generate_ciphertext(word, cipher_map)
|
| 72 |
helper_phrase.append(encrypted_word)
|
| 73 |
-
if len(" ".join(helper_phrase)) >= desired_length:
|
| 74 |
-
break
|
| 75 |
|
| 76 |
return " ".join(helper_phrase)
|
| 77 |
|
|
|
|
| 59 |
}
|
| 60 |
|
| 61 |
def generate_helper_phrase(ciphertext, cipher_map):
|
| 62 |
+
# Generate a helper phrase using three words for each letter in the ciphertext
|
| 63 |
helper_phrase = []
|
|
|
|
| 64 |
|
| 65 |
+
for letter in set(ciphertext):
|
| 66 |
+
if letter.isalpha() and letter.upper() in helper_words:
|
| 67 |
+
for _ in range(3): # Add three words for each letter
|
| 68 |
word = random.choice(helper_words[letter.upper()])
|
| 69 |
# Encrypt the helper word using the same cipher map
|
| 70 |
encrypted_word = generate_ciphertext(word, cipher_map)
|
| 71 |
helper_phrase.append(encrypted_word)
|
|
|
|
|
|
|
| 72 |
|
| 73 |
return " ".join(helper_phrase)
|
| 74 |
|