MCPcopy Create free account
hub / github.com/apache/arrow / parse_wrapped_key

Function parse_wrapped_key

python/pyarrow/tests/parquet/encryption.py:57–67  ·  view source on GitHub ↗

Parses a wrapped key string into a tuple: (key id, version, key) given input in the form: :v :

(wrapped_key: str)

Source from the content-addressed store, hash-verified

55
56
57def parse_wrapped_key(wrapped_key: str) -> tuple[str, int, bytes]:
58 """Parses a wrapped key string into a tuple: (key id, version, key) given
59 input in the form: <key id>:v<version>:<bas64 encoded key>"""
60 ptn = re.compile("(.+?):v([0-9]+?):(.+)")
61 if m := ptn.fullmatch(wrapped_key):
62 id, version, b64key = m.groups()
63 version = int(version)
64 key = base64.b64decode(b64key)
65 return (id, version, key)
66 else:
67 raise ValueError("Cannot parse wrapped key", wrapped_key)
68
69
70MASTER_KEY_VERSION = "master_key_version"

Callers 2

unwrap_keyMethod · 0.85

Calls

no outgoing calls

Tested by 1