MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / str_2_key

Function str_2_key

tests/src/util/keyhandler.py:15–25  ·  view source on GitHub ↗
(gen: str)

Source from the content-addressed store, hash-verified

13
14
15def str_2_key(gen: str) -> bytes:
16 if not gen:
17 warnings.warn("No key supplied!")
18 if (length := len(gen)) < 32:
19 warnings.warn(f"Short length {length}")
20 gen = gen.zfill(32)
21 elif length > 32:
22 warnings.warn(f"Long length {length}")
23 gen = gen[:32]
24
25 return urlsafe_b64encode(gen.encode())
26
27
28_fernet_key_raw = os.getenv("FERNET_KEY")

Callers 1

keyhandler.pyFile · 0.85

Calls 1

encodeMethod · 0.80

Tested by

no test coverage detected