Shuffled’s documentation¶
How to Use¶
-
class
shuffled.
Shuffled
(range_size, seed=None)[source]¶ Randomized integer ranges
Parameters: - range_size (int) – Size of the range
- seed (bytes) – Seed to make randomization repeatable
>>> shuffled_range = Shuffled(10) >>> list(shuffled_range) [4, 1, 2, 9, 8, 5, 3, 0, 6, 7] >>> same_shuffled_range = Shuffled(10, seed=shuffled_range.seed) >>> list(same_shuffled_range) [4, 1, 2, 9, 8, 5, 3, 0, 6, 7]
Internal APIs¶
Note
Use the following APIs at your own risk.
Index Randomization¶
-
class
shuffled.crypto.
AesRandomizer
(key)[source]¶ -
domain_size
= 340282366920938463463374607431768211456¶
-
-
class
shuffled.crypto.
IndexEncryptor
(randomizers, size)[source]¶ Encrypt indexes using pseudo-random function.
Parameters: - randomizers – List of instances with an appropriate pseudo-random
randomize
method anddomain_size
integer attribute, such asAesRandomizer
objects. - size (int) – Size of the domain
- randomizers – List of instances with an appropriate pseudo-random
Generalized-Feistel Cipher¶
-
shuffled.feistel.
encrypt
(round_functions, a, b, m, size)[source]¶ Generalized-Feistel encryption
Parameters: - round_functions (List[int -> int]) – List of pseudo-random functions with values in
range(n)
wheren >= size
- a (int) – Positive integer
- b (int) – Positive integer
- m (int) – Message to encrypt in
range(size)
- size (int) – Size of the domain
The algorithm comes from Black and Rogaway (Ciphers with Arbitrary Finite Domains, 2002).
- round_functions (List[int -> int]) – List of pseudo-random functions with values in