-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I was testing an implementation of shuffling lists using pyffx, in an attempt to avoid holding the entire shuffled list in memory. One of my implementations is as follows:
def shuffle_generator(sequence):
key = secrets.token_bytes()
cipher = pyffx.Sequence(key, alphabet=sequence, length=1)
for i in sequence:
yield cipher.encrypt([i])[0]
In tests, this quickly proved to be a terrible shuffle. The result was always a rotation of the input - for example, list(shuffle_generator(range(5))) could produce [2, 3, 4, 0, 1] or [0, 1, 2, 3, 4], but never [0, 4, 2, 3, 1].
Am I using pyffx wrong in some way I'm not realizing?
I'm on pyffx 0.3.0 and Python 3.8.3.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels