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

Function __decrypt_part

ciphers/trifid_cipher.py:40–59  ·  view source on GitHub ↗

Convert each letter of the input string into their respective trigram values, join them and split them into three equal groups of strings which are returned. >>> __decrypt_part('ABCDE', TEST_CHARACTER_TO_NUMBER) ('11111', '21131', '21122')

(
    message_part: str, character_to_number: dict[str, str]
)

Source from the content-addressed store, hash-verified

38
39
40def __decrypt_part(
41 message_part: str, character_to_number: dict[str, str]
42) -> tuple[str, str, str]:
43 """
44 Convert each letter of the input string into their respective trigram values, join
45 them and split them into three equal groups of strings which are returned.
46
47 >>> __decrypt_part('ABCDE', TEST_CHARACTER_TO_NUMBER)
48 ('11111', '21131', '21122')
49 """
50 this_part = "".join(character_to_number[character] for character in message_part)
51 result = []
52 tmp = ""
53 for digit in this_part:
54 tmp += digit
55 if len(tmp) == len(message_part):
56 result.append(tmp)
57 tmp = ""
58
59 return result[0], result[1], result[2]
60
61
62def __prepare(

Callers 1

decrypt_messageFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected