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

Function get_text_from_blocks

ciphers/rsa_cipher.py:24–36  ·  view source on GitHub ↗
(
    block_ints: list[int], message_length: int, block_size: int = DEFAULT_BLOCK_SIZE
)

Source from the content-addressed store, hash-verified

22
23
24def get_text_from_blocks(
25 block_ints: list[int], message_length: int, block_size: int = DEFAULT_BLOCK_SIZE
26) -> str:
27 message: list[str] = []
28 for block_int in block_ints:
29 block_message: list[str] = []
30 for i in range(block_size - 1, -1, -1):
31 if len(message) + i < message_length:
32 ascii_number = block_int // (BYTE_SIZE**i)
33 block_int = block_int % (BYTE_SIZE**i)
34 block_message.insert(0, chr(ascii_number))
35 message.extend(block_message)
36 return "".join(message)
37
38
39def encrypt_message(

Callers 1

decrypt_messageFunction · 0.85

Calls 2

insertMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected