1
0

util.randrange: expand docstring

This commit is contained in:
SomberNight
2023-08-16 16:32:42 +00:00
parent 5e1e7dd9b3
commit 2c2e3f8ca4

View File

@@ -1724,7 +1724,9 @@ def resolve_dns_srv(host: str):
def randrange(bound: int) -> int:
"""Return a random integer k such that 1 <= k < bound, uniformly
distributed across that range."""
distributed across that range.
This is guaranteed to be cryptographically strong.
"""
# secrets.randbelow(bound) returns a random int: 0 <= r < bound,
# hence transformations:
return secrets.randbelow(bound - 1) + 1