diff options
author | Richard van der Hoff <richard@matrix.org> | 2019-05-03 19:24:42 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2019-05-03 19:24:42 +0100 |
commit | 9b86d3dee69702cd9fa02e7f454fd0e92a7761bb (patch) | |
tree | 73bc79d1abde252d6433a6ccfd5ca7956589588e /synapse/util | |
parent | add gpg key fingerprint (diff) | |
parent | 0.99.3.2 (diff) | |
download | synapse-9b86d3dee69702cd9fa02e7f454fd0e92a7761bb.tar.xz |
Merge tag 'v0.99.3.2'
Synapse 0.99.3.2 (2019-05-03) ============================= Internal Changes ---------------- - Ensure that we have `urllib3` <1.25, to resolve incompatibility with `requests`. ([\#5135](https://github.com/matrix-org/synapse/issues/5135))
Diffstat (limited to 'synapse/util')
-rw-r--r-- | synapse/util/stringutils.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/util/stringutils.py b/synapse/util/stringutils.py index fdcb375f95..69dffd8244 100644 --- a/synapse/util/stringutils.py +++ b/synapse/util/stringutils.py @@ -24,14 +24,19 @@ _string_with_symbols = ( string.digits + string.ascii_letters + ".,;:^&*-_+=#~@" ) +# random_string and random_string_with_symbols are used for a range of things, +# some cryptographically important, some less so. We use SystemRandom to make sure +# we get cryptographically-secure randoms. +rand = random.SystemRandom() + def random_string(length): - return ''.join(random.choice(string.ascii_letters) for _ in range(length)) + return ''.join(rand.choice(string.ascii_letters) for _ in range(length)) def random_string_with_symbols(length): return ''.join( - random.choice(_string_with_symbols) for _ in range(length) + rand.choice(_string_with_symbols) for _ in range(length) ) |