diff --git a/etiquette/helpers.py b/etiquette/helpers.py index 0c77edc..7238586 100644 --- a/etiquette/helpers.py +++ b/etiquette/helpers.py @@ -379,12 +379,6 @@ def parse_unit_string(s): else: return bytestring.parsebytes(s) -def random_hex(length=12): - randbytes = os.urandom(math.ceil(length / 2)) - token = ''.join('{:02x}'.format(x) for x in randbytes) - token = token[:length] - return token - def read_filebytes(filepath, range_min=0, range_max=None, chunk_size=bytestring.MIBIBYTE): ''' Yield chunks of bytes from the file between the endpoints. diff --git a/etiquette/photodb.py b/etiquette/photodb.py index f26c308..349b051 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -11,6 +11,7 @@ import types from voussoirkit import cacheclass from voussoirkit import configlayers from voussoirkit import expressionmatch +from voussoirkit import passwordy from voussoirkit import pathclass from voussoirkit import ratelimiter from voussoirkit import spinal @@ -1077,7 +1078,7 @@ class PDBSQLMixin: self.on_commit_queue.clear() def savepoint(self, message=None): - savepoint_id = helpers.random_hex(length=16) + savepoint_id = passwordy.random_hex(length=16) if message: self.log.log(5, 'Savepoint %s for %s.', savepoint_id, message) else: diff --git a/frontends/etiquette_flask/backend/caching.py b/frontends/etiquette_flask/backend/caching.py index 7a053ba..63e678f 100644 --- a/frontends/etiquette_flask/backend/caching.py +++ b/frontends/etiquette_flask/backend/caching.py @@ -3,6 +3,7 @@ import functools import time from voussoirkit import cacheclass +from voussoirkit import passwordy import etiquette @@ -48,7 +49,7 @@ def cached_endpoint(max_age): value = value.response if value != state['stored_value']: state['stored_value'] = value - state['stored_etag'] = etiquette.helpers.random_hex(20) + state['stored_etag'] = passwordy.random_hex(20) state['headers']['ETag'] = state['stored_etag'] state['last_run'] = time.time() else: diff --git a/frontends/etiquette_flask/backend/sessions.py b/frontends/etiquette_flask/backend/sessions.py index 953311a..5dc5669 100644 --- a/frontends/etiquette_flask/backend/sessions.py +++ b/frontends/etiquette_flask/backend/sessions.py @@ -4,6 +4,7 @@ import werkzeug.wrappers import werkzeug.datastructures from voussoirkit import cacheclass +from voussoirkit import passwordy import etiquette @@ -12,7 +13,7 @@ REQUEST_TYPES = (flask.Request, werkzeug.wrappers.Request, werkzeug.local.LocalP RESPONSE_TYPES = (flask.Response, werkzeug.wrappers.Response) def _generate_token(length=32): - return etiquette.helpers.random_hex(length=length) + return passwordy.random_hex(length=length) def _normalize_token(token): if isinstance(token, REQUEST_TYPES):