From 78dbea765e02cc9791f69fe46b843c339579359d Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Tue, 26 Apr 2022 00:18:23 +0900 Subject: [PATCH] Add comments about magic numbers (#74) --- src/trops/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/trops/utils.py b/src/trops/utils.py index 13e9040..65f8c2b 100644 --- a/src/trops/utils.py +++ b/src/trops/utils.py @@ -48,11 +48,12 @@ def tranquility(): def generate_sid(args, other_args): """Generate a session ID""" s = tranquility() + # Three is a magic number hlen = 3 tlen = 4 n = randint(0, len(s)-hlen) now = datetime.now().isoformat() head = ''.join(list(s)[n:n+hlen]).lower() tail = hashlib.sha256(bytes(now, 'utf-8')).hexdigest()[0:tlen] - + # Seven is also a magic number print(head + tail)