diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2019-05-14 11:43:03 +0100 |
---|---|---|
committer | Brendan Abolivier <babolivier@matrix.org> | 2019-05-14 11:43:03 +0100 |
commit | f608ddbe5c58f35b76c5b1199c60a6c17a684d19 (patch) | |
tree | cfc254400db8c0d3d9cdcef7942e935b09ba4f1d /synapse/util | |
parent | Merge pull request #5115 from matrix-org/babolivier/lookup_path (diff) | |
parent | 0.99.4rc1 (diff) | |
download | synapse-f608ddbe5c58f35b76c5b1199c60a6c17a684d19.tar.xz |
Merge branch 'release-v0.99.4' into dinsic dinsic_2019-05-14
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) ) |