veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

codec/pem

lib/codec/pem.vk

lib/codec/pem.vk Pure-Veko RFC 4648 Base64 and PEM (-----BEGIN ...-----) decoder/encoder. Includes pem-to-block for declarative parse-block inspection.

signature
b64-decode = fn [text str] any

Decodes a standard or URL-safe Base64 string into raw bytes (ignoring ASCII whitespace).

Executable Example
veko
use [pem = codec/pem]
enc = pem/b64-encode (bytes/from-str 'Veko 1.0')
dec = pem/b64-decode enc
if enc != 'VmVrbyAxLjA=' or (bytes/to-str dec) != 'Veko 1.0' [ err 'pem b64' ] else [ .ok ]
signature
b64-encode = fn [data bytes] str

Encodes data into standard RFC 4648 Base64 text.

signature
pem-decode-all = fn [text str] any

Parses all PEM blocks in text, returning a block of { label, der } maps.

signature
pem-decode = fn [text str, expected_label str] any

Extracts the first PEM block matching expected_label (or any block if expected_label == '').

signature
pem-encode = fn [label str, der bytes] str

Encodes der bytes into a standard 64-column wrapped PEM string.

signature
pem-to-block = fn [text str] any

Converts decoded PEM blocks to [ .pem label der ... ] for declarative parse-block matching.