You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@steve.apache.org by gs...@apache.org on 2022/05/31 00:54:22 UTC
[steve] 01/02: helper shuffle() function
This is an automated email from the ASF dual-hosted git repository.
gstein pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/steve.git
commit 4b6102871f9ae014afccd7a1831868151756477f
Author: Greg Stein <gs...@gmail.com>
AuthorDate: Mon May 30 19:53:43 2022 -0500
helper shuffle() function
---
v3/steve/crypto.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/v3/steve/crypto.py b/v3/steve/crypto.py
index 6974937..47943d3 100644
--- a/v3/steve/crypto.py
+++ b/v3/steve/crypto.py
@@ -19,6 +19,7 @@
#
import base64
+import random
import passlib.hash # note that .argon2 is proxy in this pkg
import passlib.utils # for the RNG, to create Salt values
@@ -73,3 +74,8 @@ def _hash(data: bytes, salt: bytes) -> bytes:
ph = passlib.hash.argon2.using(type='d', salt=salt)
h = ph.hash(data)
return base64.standard_b64decode(h.split('$')[-1] + '==')
+
+
+def shuffle(x):
+ "Ensure we use the strongest RNG available for shuffling."
+ return random.shuffle(x, passlib.utils.rng.random)