28 releases (14 stable)

3.0.6 Oct 10, 2025
3.0.5 Feb 21, 2025
3.0.4 Apr 8, 2024
3.0.3 Dec 12, 2023
0.2.0 Mar 14, 2016

#8 in Cryptography

Download history 2192727/week @ 2025-12-13 1202755/week @ 2025-12-20 1022948/week @ 2025-12-27 2079476/week @ 2026-01-03 2467538/week @ 2026-01-10 2496715/week @ 2026-01-17 2626993/week @ 2026-01-24 2729547/week @ 2026-01-31 2867123/week @ 2026-02-07 2667306/week @ 2026-02-14 2886280/week @ 2026-02-21 3503798/week @ 2026-02-28 3753283/week @ 2026-03-07 3337201/week @ 2026-03-14 3120178/week @ 2026-03-21 3298744/week @ 2026-03-28

14,143,534 downloads per month
Used in 4,427 crates (340 directly)

MIT license

47KB
829 lines

pem

A Rust library for parsing and encoding PEM-encoded data.

Build Status

Documentation

Module documentation with examples

Usage

Add this to your Cargo.toml:

[dependencies]
pem = "3.0"

Here is a simple example that parse PEM-encoded data and prints the tag:

use pem::parse;

const SAMPLE: &'static str = "-----BEGIN RSA PRIVATE KEY-----
MIIBPQIBAAJBAOsfi5AGYhdRs/x6q5H7kScxA0Kzzqe6WI6gf6+tc6IvKQJo5rQc
dWWSQ0nRGt2hOPDO+35NKhQEjBQxPh/v7n0CAwEAAQJBAOGaBAyuw0ICyENy5NsO
2gkT00AWTSzM9Zns0HedY31yEabkuFvrMCHjscEF7u3Y6PB7An3IzooBHchsFDei
AAECIQD/JahddzR5K3A6rzTidmAf1PBtqi7296EnWv8WvpfAAQIhAOvowIXZI4Un
DXjgZ9ekuUjZN+GUQRAVlkEEohGLVy59AiEA90VtqDdQuWWpvJX0cM08V10tLXrT
TTGsEtITid1ogAECIQDAaFl90ZgS5cMrL3wCeatVKzVUmuJmB/VAmlLFFGzK0QIh
ANJGc7AFk4fyFD/OezhwGHbWmo/S+bfeAiIh2Ss2FxKJ
-----END RSA PRIVATE KEY-----
";

let pem = parse(SAMPLE)?;
println!("PEM tag: {}", pem.tag);

Dependencies

~165–310KB