Manuscript Documentation
v2026.12.0

@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.

Manuscript
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.

Manuscript
data Bytes

PemBlock.headers#

Header fields written before the body, in order; empty for modern PEM.

Manuscript
headers Map[String, String] = Map[String, String]()

PemBlock.label#

Text between BEGIN and the closing dashes, such as CERTIFICATE.

Manuscript
label String

encode_all Function#

Encodes blocks in order into one PEM text; the result parses back to equal blocks.

Manuscript
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.

Manuscript
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.

Manuscript
fn parse(text String) Result[List[PemBlock], Error] { ... }