18 from base64
import b64decode
23 def _projectKeyEnvName(projectId: int) -> str:
24 return f
"CTX_PROJECT_KEY_{projectId}"
27 def getProjectKey(projectId: int) -> bytes:
29 Retrieves encryption key for provided project if
30 the executing machine has been authorized to access it
35 project whose key is being retrieved
39 bytes -> encryption key
42 envName = _projectKeyEnvName(projectId)
43 if envName
not in os.environ:
44 raise RuntimeError(f
"Not authorized to access project: {projectId}")
46 encodedKey = os.environ[envName]
47 return b64decode(encodedKey)