MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / decode

Function decode

tools/provenance-export/verify_dsse.py:62–73  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

60
61
62def decode(value):
63 if not isinstance(value, str):
64 raise ValueError("base64 member must be a string")
65 for altchars in (None, b"-_"):
66 try:
67 decoded = base64.b64decode(value, altchars=altchars, validate=True)
68 encoded = base64.b64encode(decoded, altchars=altchars).decode("ascii")
69 if value == encoded:
70 return decoded
71 except (ValueError, UnicodeError):
72 pass
73 raise ValueError("noncanonical base64")
74
75
76def verify(raw, key_bytes):

Callers 1

verifyFunction · 0.70

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected