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

Function cipher_text

ciphers/beaufort_cipher.py:33–47  ·  view source on GitHub ↗

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

(message: str, key_new: str)

Source from the content-addressed store, hash-verified

31# This function returns the encrypted text
32# generated with the help of the key
33def 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

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected