Skip to main content

encode

Function encode 

Source
pub fn encode(label: &str, der: &[u8]) -> String
Expand description

Encode der as a PEM block with the given label. Output is the strict RFC 1421 form: 64 chars per line, LF terminators, no trailing whitespace.

label must be ASCII per RFC 7468 §2 — non-ASCII labels would round-trip but reject under strict-conformant decoders. The callers in this crate use fixed labels ("PRIVATE KEY", "PUBLIC KEY", "ENCRYPTED PRIVATE KEY", "EC PRIVATE KEY"), all ASCII.

§Panics

Never (encoded length is bounded by 4 · der.len() / 3 + small, well below the Vec allocation ceiling on any realistic input).