X-Git-Url: https://git.mar77i.info/?a=blobdiff_plain;f=hub%2Futils.py;fp=hub%2Futils.py;h=c9d955cfa107e1e6cc01f5d7a7ea1b3d1e9a23d1;hb=c0e574584af0d45070e5fa81fcbcd1dccc2c5a42;hp=0000000000000000000000000000000000000000;hpb=d23acd0d6d03d822e4505c64f71587f55e8dc2b6;p=hublib diff --git a/hub/utils.py b/hub/utils.py new file mode 100644 index 0000000..c9d955c --- /dev/null +++ b/hub/utils.py @@ -0,0 +1,18 @@ +from base64 import urlsafe_b64encode +from hashlib import sha3_512 + + +def scramble(secret, value): + h = sha3_512() + h.update(f"{secret}{value}".encode()) + return urlsafe_b64encode(h.digest()).rstrip(b"=").decode("ascii") + + +def get_redis_pass(redis_conf): + prefix = "requirepass " + with open(redis_conf, "rt") as fh: + for line in fh: + if not line.startswith(prefix): + continue + return line[len(prefix) :].rstrip() + return None