I need 32 byte pseudorandom sequences that denote unique filenames and am currently using this Python code:
import base64
import hashlib
from django.utils import timezone
from uuid import uuid4
def get_name():
data = str(uuid4()) + str(timezone.now())
hash = base64.b64encode(hashlib.sha256(
data.encode()).digest(), '-_'.encode()).decode()[:-1]
Do you think it's necessary to check if the generated sequence doesn't collide with any previously generated sequences or can I just skip the overhead of checking, trusting the function?
SystemRandom
. $\endgroup$SystemRandom
to the mix $\endgroup$