]> git.mar77i.info Git - hublib/blob - hub/utils.py
functioning basic chat app
[hublib] / hub / utils.py
1 from base64 import urlsafe_b64encode
2 from hashlib import sha3_512
3
4
5 def scramble(secret, value):
6 h = sha3_512()
7 h.update(f"{secret}{value}".encode())
8 return urlsafe_b64encode(h.digest()).rstrip(b"=").decode("ascii")
9
10
11 def get_redis_pass(redis_conf):
12 prefix = "requirepass "
13 with open(redis_conf, "rt") as fh:
14 for line in fh:
15 if not line.startswith(prefix):
16 continue
17 return line[len(prefix) :].rstrip()
18 return None