>>> cipher_text("THE GERMAN ATTACK","SECRETSECRETSECRE") 'BDC PAYUWL JPAIYI'
(message: str, key_new: str)
| 31 | # This function returns the encrypted text |
| 32 | # generated with the help of the key |
| 33 | def cipher_text(message: str, key_new: str) -> str: |
| 34 | """ |
| 35 | >>> cipher_text("THE GERMAN ATTACK","SECRETSECRETSECRE") |
| 36 | 'BDC PAYUWL JPAIYI' |
| 37 | """ |
| 38 | cipher_text = "" |
| 39 | i = 0 |
| 40 | for letter in message: |
| 41 | if letter == " ": |
| 42 | cipher_text += " " |
| 43 | else: |
| 44 | x = (dict1[letter] - dict1[key_new[i]]) % 26 |
| 45 | i += 1 |
| 46 | cipher_text += dict2[x] |
| 47 | return cipher_text |
| 48 | |
| 49 | |
| 50 | # This function decrypts the encrypted text |