Generate a random permutation key of a specified block size. Args: block_size (int): The size of each permutation block. Returns: list[int]: A list containing a random permutation of digits. Example: >>> random.seed(0) >>> generate_permutation_key(
(block_size: int)
| 35 | |
| 36 | |
| 37 | def generate_permutation_key(block_size: int) -> list[int]: |
| 38 | """ |
| 39 | Generate a random permutation key of a specified block size. |
| 40 | |
| 41 | Args: |
| 42 | block_size (int): The size of each permutation block. |
| 43 | |
| 44 | Returns: |
| 45 | list[int]: A list containing a random permutation of digits. |
| 46 | |
| 47 | Example: |
| 48 | >>> random.seed(0) |
| 49 | >>> generate_permutation_key(4) |
| 50 | [2, 0, 1, 3] |
| 51 | """ |
| 52 | digits = list(range(block_size)) |
| 53 | random.shuffle(digits) |
| 54 | return digits |
| 55 | |
| 56 | |
| 57 | def encrypt( |