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

Function get_blocks_from_text

ciphers/rsa_cipher.py:10–21  ·  view source on GitHub ↗
(
    message: str, block_size: int = DEFAULT_BLOCK_SIZE
)

Source from the content-addressed store, hash-verified

8
9
10def get_blocks_from_text(
11 message: str, block_size: int = DEFAULT_BLOCK_SIZE
12) -> list[int]:
13 message_bytes = message.encode("ascii")
14
15 block_ints = []
16 for block_start in range(0, len(message_bytes), block_size):
17 block_int = 0
18 for i in range(block_start, min(block_start + block_size, len(message_bytes))):
19 block_int += message_bytes[i] * (BYTE_SIZE ** (i % block_size))
20 block_ints.append(block_int)
21 return block_ints
22
23
24def get_text_from_blocks(

Callers 1

encrypt_messageFunction · 0.85

Calls 2

encodeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected