File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -9,10 +9,18 @@ import base64
9
9
import hashlib
10
10
import hmac
11
11
import re
12
- import secrets
13
12
import stringprep
14
13
import unicodedata
15
14
15
+
16
+ # try to import the secrets library from Python 3.6+ for the
17
+ # cryptographic token generator for generating nonces as part of SCRAM
18
+ # Otherwise fall back on os.urandom
19
+ try :
20
+ from secrets import token_bytes as generate_token_bytes
21
+ except ImportError :
22
+ from os import urandom as generate_token_bytes
23
+
16
24
@cython.final
17
25
cdef class SCRAMAuthentication:
18
26
""" Contains the protocol for generating and a SCRAM hashed password.
@@ -190,7 +198,7 @@ cdef class SCRAMAuthentication:
190
198
cdef:
191
199
bytes token
192
200
193
- token = secrets. generate_token_bytes(num_bytes)
201
+ token = generate_token_bytes(num_bytes)
194
202
195
203
return base64.b64encode(token)
196
204
You can’t perform that action at this time.
0 commit comments