(
message: str, block_size: int = DEFAULT_BLOCK_SIZE
)
| 8 | |
| 9 | |
| 10 | def 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 | |
| 24 | def get_text_from_blocks( |
no test coverage detected