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

Function generate_permutation_key

ciphers/permutation_cipher.py:37–54  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

35
36
37def 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
57def encrypt(

Callers 1

encryptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected