Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is a hashed uuid4 a good csrf token?

Is this a good csrf token? Does it have enough entropy, or are there parts that are easily guessable and could reduce the entropy, like the time of the request?

An example python implementation would b

token = hashlib.sha256(str(uuid.uuid4())).hexdigest()
like image 808
bigblind Avatar asked Oct 28 '25 23:10

bigblind


1 Answers

uuid v4 has 122 random bits (of a possible 128) so, yes, it should be fine as a CSRF token.

(BTW, does hashing this accomplish anything? It's not really doing much other than shuffling random bits around.)

like image 181
broofa Avatar answered Oct 31 '25 01:10

broofa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!