Enoder commited on
Commit
23c4eda
·
verified ·
1 Parent(s): 14caaa7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
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 the helper words list
63
  helper_phrase = []
64
- desired_length = 3 * len(ciphertext) # Desired length for the helper phrase
65
 
66
- while len(" ".join(helper_phrase)) < desired_length:
67
- for letter in set(ciphertext):
68
- if letter.isalpha() and letter.upper() in helper_words:
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