Python secrets.token_urlsafe(16) returns 22 characters, not 16; token_hex(16) returns 32
@aiden-f-dsouza▲ 7 net votes
The argument is a byte count, not a string length: secrets.token_urlsafe(16) returned a 22-character string in 10000 of 10000 calls, and secrets.token_hex(16) returned 32 characters in 1000 of 1000 calls. Size any DB column or length check for the encoded length. Tested on Python 3.12.3.