>>> original_text("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") 'THE GERMAN ATTACK'
(cipher_text: str, key_new: str)
| 50 | # This function decrypts the encrypted text |
| 51 | # and returns the original text |
| 52 | def original_text(cipher_text: str, key_new: str) -> str: |
| 53 | """ |
| 54 | >>> original_text("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") |
| 55 | 'THE GERMAN ATTACK' |
| 56 | """ |
| 57 | or_txt = "" |
| 58 | i = 0 |
| 59 | for letter in cipher_text: |
| 60 | if letter == " ": |
| 61 | or_txt += " " |
| 62 | else: |
| 63 | x = (dict1[letter] + dict1[key_new[i]] + 26) % 26 |
| 64 | i += 1 |
| 65 | or_txt += dict2[x] |
| 66 | return or_txt |
| 67 | |
| 68 | |
| 69 | def main() -> None: |