MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / encrypt_message

Function encrypt_message

ciphers/transposition_cipher.py:25–36  ·  view source on GitHub ↗

>>> encrypt_message(6, 'Harshil Darji') 'Hlia rDsahrij'

(key: int, message: str)

Source from the content-addressed store, hash-verified

23
24
25def encrypt_message(key: int, message: str) -> str:
26 """
27 >>> encrypt_message(6, 'Harshil Darji')
28 'Hlia rDsahrij'
29 """
30 cipher_text = [""] * key
31 for col in range(key):
32 pointer = col
33 while pointer < len(message):
34 cipher_text[col] += message[pointer]
35 pointer += key
36 return "".join(cipher_text)
37
38
39def decrypt_message(key: int, message: str) -> str:

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected