Kedvtelésből írom ezt a kódot, ami arra szolgál, hogy jegyzeteket blokkláncba mentsen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB

"""Generate cryptographically strong pseudo-random numbers suitable for
managing secrets such as account authentication, tokens, and similar.
See PEP 506 for more information.
Amit nem hasznalok belole azt kivettem!
Eredeti forras:
__all__ = ['choice', 'randbelow', 'randbits', 'SystemRandom',
'token_bytes', 'token_hex', 'token_urlsafe',
import base64
import binascii
import os
from hmac import compare_digest
from random import SystemRandom
_sysrand = SystemRandom()
randbits = _sysrand.getrandbits
choice = _sysrand.choice
DEFAULT_ENTROPY = 64 # number of bytes to return by default
def token_bytes(nbytes=None):
"""Return a random byte string containing *nbytes* bytes.
>>> token_bytes(16) #doctest:+SKIP
if nbytes is None:
return os.urandom(nbytes)
def token_hex(nbytes=None):
"""Return a random text string, in hexadecimal.
>>> token_hex(16) #doctest:+SKIP
return binascii.hexlify(token_bytes(nbytes)).decode('ascii')