@std/data/pem.ms#
Import each required symbol with import Name from "@std/data/pem.ms".
PemBlock Type#
One PEM block: its label, optional RFC 1421 style headers, and decoded body bytes.
type PemBlock {
label String
data Bytes
headers Map[String, String] = Map[String, String]()
}PemBlock.data#
Decoded body bytes; empty for a block with no body lines.
data BytesPemBlock.headers#
Header fields written before the body, in order; empty for modern PEM.
headers Map[String, String] = Map[String, String]()PemBlock.label#
Text between BEGIN and the closing dashes, such as CERTIFICATE.
label Stringencode_all Function#
Encodes blocks in order into one PEM text; the result parses back to equal blocks.
fn encode_all(blocks List[PemBlock]) String { ... }encode_block Function#
Encodes one block with headers first, then the body in 64-character base64 lines, ending with a newline.
fn encode_block(block PemBlock) String { ... }parse Function#
Parses every PEM block in text. Text outside blocks is ignored, and a text without
blocks gives an empty list. Mismatched, nested or unterminated armor, or a body that
is not valid Base64, returns an Error with kind EBADMSG.
fn parse(text String) Result[List[PemBlock], Error] { ... }