Browse Source

util.randrange: expand docstring

master
SomberNight 2 years ago
parent
commit
2c2e3f8ca4
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/util.py

4
electrum/util.py

@ -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

Loading…
Cancel
Save