Use bytes.hex() in secrets.token_hex()

This commit is contained in:
sweeneyde 2020-04-28 02:41:45 -04:00
parent 3d53d8756f
commit c7ab0d9db5
1 changed files with 1 additions and 2 deletions

View File

@ -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.