Use bytes.hex() in secrets.token_hex()
This commit is contained in:
parent
3d53d8756f
commit
c7ab0d9db5
|
@ -13,7 +13,6 @@ __all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom',
|
|||
|
||||
|
||||
import base64
|
||||
import binascii
|
||||
|
||||
from hmac import compare_digest
|
||||
from random import SystemRandom
|
||||
|
@ -56,7 +55,7 @@ def token_hex(nbytes=None):
|
|||
'f9bf78b9a18ce6d46a0cd2b0b86df9da'
|
||||
|
||||
"""
|
||||
return binascii.hexlify(token_bytes(nbytes)).decode('ascii')
|
||||
return token_bytes(nbytes).hex()
|
||||
|
||||
def token_urlsafe(nbytes=None):
|
||||
"""Return a random URL-safe text string, in Base64 encoding.
|
||||
|
|
Loading…
Reference in New Issue