View Source PEM (PEM v0.1.0)
Implementation of rfc7468 (https://tools.ietf.org/html/rfc7468) encoding and decoding of PEM binaries.
Link to this section Summary
Link to this section Functions
Decodes the given PEM encoded content.
iex> PEM.decode("-----BEGIN TEST-----\nSGVsbG8gV29ybGQ=\n-----END TEST-----\n")
{:ok, "Hello World"}
You can optionally pass strict: true
to enforce stricter validation of the PEM content.
iex> PEM.decode("-----BEGIN TEST1-----\nSGVsbG8gV29ybGQ=\n-----END TEST2-----\n", strict: true)
{:error, :different_labels}
You can also pass enforce_label: ""
to enforce the label of the PEM content.
iex> PEM.decode("-----BEGIN TEST-----\nSGVsbG8gV29ybGQ=\n-----END TEST-----\n", enforce_label: "TEST1")
{:error, :header_label_mismatch}
Encodes the given content with the given label.
iex> PEM.encode("Hello World", "TEST")
"-----BEGIN TEST-----
SGVsbG8gV29ybGQ=
-----END TEST-----
"