summary refs log tree commit diff
path: root/synapse/util/stringutils.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2019-05-08 16:29:45 -0500
committerAmber Brown <hawkowl@atleastfornow.net>2019-05-08 16:29:45 -0500
commitfaee1e9baba74b08fb991d57effd06f87147fc76 (patch)
treeb15c6241318be63f4043c018964b2f7382b65738 /synapse/util/stringutils.py
parentMerge remote-tracking branch 'origin/develop' into shhs (diff)
parentFix bogus imports in tests (#5154) (diff)
downloadsynapse-faee1e9baba74b08fb991d57effd06f87147fc76.tar.xz
Merge remote-tracking branch 'origin/develop' into shhs
Diffstat (limited to 'synapse/util/stringutils.py')
-rw-r--r--synapse/util/stringutils.py9
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) )