codec/pem
lib/codec/pem.vklib/codec/pem.vk
Pure-Veko RFC 4648 Base64 and PEM (-----BEGIN ...-----) decoder/encoder.
Includes pem-to-block for declarative parse-block inspection.
b64-decode = fn [text str] any
Decodes a standard or URL-safe Base64 string into raw bytes (ignoring ASCII whitespace).
Executable Example
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 ]
pem-decode-all = fn [text str] any
Parses all PEM blocks in text, returning a block of { label, der } maps.
pem-decode = fn [text str, expected_label str] any
Extracts the first PEM block matching expected_label (or any block if expected_label == '').
pem-encode = fn [label str, der bytes] str
Encodes der bytes into a standard 64-column wrapped PEM string.
pem-to-block = fn [text str] any
Converts decoded PEM blocks to [ .pem label der ... ] for declarative parse-block matching.