Sample
pem 3.0.6: pem::encode
Verified sample for cargo pem 3.0.6: pem::encode. The contract ran on rust 1 · linux alpine/x64 · docker and passed: pem::encode formats a Pem value with…
sha256:a97ef46b0604a2031bd15c3d57ef2642c2ff814754c7832ac7827b06303e50df
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux x64 cargo
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-11-22 |
Case
HOW- Goal
- verify pem::encode in pkg:cargo/pem@3.0.6
- Packages
- Symbols
-
- pem::encode
- Created
- 2026-11-22T17:27:13Z
Contract
- pem::encode formats a Pem value with -----BEGIN <tag>----- and -----END <tag>----- framing, standard padded Base64 payload, and CRLF line endings matching Display
- pem::encode wraps Base64 output at 64 characters per line using EncodeConfig::default() and round-trips identically through pem::parse
- pem::encode omits payload lines when Pem::contents is empty and emits headers followed by a blank CRLF separator line when headers are present
Files
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/main.rs
- tests/contract.rs
Source
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "base64"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "pem"
version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be"
dependencies = [
"base64",
"serde_core",
]
[[package]]
name = "proc-macro2"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
dependencies = [
"proc-macro2",
]
[[package]]
name = "sample-pem-encode"
version = "0.1.0"
dependencies = [
"pem",
]
[[package]]
name = "serde_core"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.229"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "syn"
version = "3.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
[package]
name = "sample-pem-encode"
version = "0.1.0"
edition = "2021"
[dependencies]
pem = "=3.0.6"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pem::encode in pkg:cargo/pem@3.0.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/pem@3.0.6
Demonstrate these symbols/APIs:
- pem::encode
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:5183c9d638464f3fa3f67ca4405a21602c617cdfae08ccbb5a0f64fe05b2a081","contract":["pem::encode formats a Pem value with -----BEGIN \u003ctag\u003e----- and -----END \u003ctag\u003e----- framing, standard padded Base64 payload, and CRLF line endings matching Display","pem::encode wraps Base64 output at 64 characters per line using EncodeConfig::default() and round-trips identically through pem::parse","pem::encode omits payload lines when Pem::contents is empty and emits headers followed by a blank CRLF separator line when headers are present"],"goal":"verify pem::encode in pkg:cargo/pem@3.0.6","kind":"HOW","packages":["pkg:cargo/pem@3.0.6"],"schemaVersion":1,"symbols":["pem::encode"]},"contractCommand":["cargo","test","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/pem@3.0.6"],"schemaVersion":1,"subject":"pkg:cargo/pem@3.0.6","symbols":["pem::encode"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pem::encode in pkg:cargo/pem@3.0.6",
"kind": "HOW",
"packages": [
"pkg:cargo/pem@3.0.6"
],
"symbols": [
"pem::encode"
]
}
use pem::{encode, Pem};
fn main() {
let pem = Pem::new("MESSAGE", b"hello pem".to_vec());
let encoded = encode(&pem);
assert_eq!(
encoded,
"-----BEGIN MESSAGE-----\r\naGVsbG8gcGVt\r\n-----END MESSAGE-----\r\n"
);
println!("CONTRACT_OK");
}
use pem::{encode, parse, Pem};
#[test]
fn encodes_basic_block_with_crlf_and_standard_base64() {
let block = Pem::new("SAMPLE DATA", [1u8, 2, 3, 4]);
let encoded = encode(&block);
assert_eq!(
encoded,
"-----BEGIN SAMPLE DATA-----\r\nAQIDBA==\r\n-----END SAMPLE DATA-----\r\n"
);
assert_eq!(format!("{block}"), encoded);
let parsed = parse(&encoded).expect("encoded PEM should parse back");
assert_eq!(parsed, block);
}
#[test]
fn wraps_base64_payload_at_64_characters_per_line() {
// 60 raw bytes produce 80 base64 characters: 64 on line 1, 16 on line 2.
let payload: Vec<u8> = (0u8..60u8).collect();
let block = Pem::new("WRAPPED", payload.clone());
let encoded = encode(&block);
let lines: Vec<&str> = encoded.split("\r\n").collect();
assert_eq!(lines.len(), 5);
assert_eq!(lines[0], "-----BEGIN WRAPPED-----");
assert_eq!(lines[1].len(), 64);
assert_eq!(lines[2].len(), 16);
assert_eq!(lines[3], "-----END WRAPPED-----");
assert_eq!(lines[4], "");
let parsed = parse(&encoded).expect("wrapped PEM should round-trip");
assert_eq!(parsed.tag(), "WRAPPED");
assert_eq!(parsed.contents(), payload.as_slice());
}
#[test]
fn encodes_empty_contents_without_payload_line() {
let block = Pem::new("EMPTY", Vec::<u8>::new());
let encoded = encode(&block);
assert_eq!(
encoded,
"-----BEGIN EMPTY-----\r\n-----END EMPTY-----\r\n"
);
let parsed = parse(&encoded).expect("empty PEM should parse back");
assert_eq!(parsed.tag(), "EMPTY");
assert!(parsed.contents().is_empty());
}
#[test]
fn encodes_headers_followed_by_blank_crlf_line() {
let mut block = Pem::new("HEADERED", b"ok".to_vec());
block.headers_mut().add("Proc-Type", "4,PLAIN").unwrap();
block.headers_mut().add("Version", "1").unwrap();
let encoded = encode(&block);
assert_eq!(
encoded,
"-----BEGIN HEADERED-----\r\nProc-Type: 4,PLAIN\r\nVersion: 1\r\n\r\nb2s=\r\n-----END HEADERED-----\r\n"
);
let parsed = parse(&encoded).expect("headered PEM should parse back");
assert_eq!(parsed, block);
assert_eq!(parsed.headers().get("Proc-Type"), Some("4,PLAIN"));
assert_eq!(parsed.headers().get("Version"), Some("1"));
}
Origin Seeder
anonymous