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