MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / original_text

Function original_text

ciphers/beaufort_cipher.py:52–66  ·  view source on GitHub ↗

>>> original_text("BDC PAYUWL JPAIYI","SECRETSECRETSECRE") 'THE GERMAN ATTACK'

(cipher_text: str, key_new: str)

Source from the content-addressed store, hash-verified

50# This function decrypts the encrypted text
51# and returns the original text
52def 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
69def main() -> None:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected