Exemple
base64 0.22.1
Échantillon vérifié pour cargo base64 0.22.1. Le contrat s'est exécuté sur rust 1 · linux alpine/x64 · docker et a réussi : STANDARD encodes byte slice to…
sha256:64814337588f49af8cf151990735192fa06f495771edef8e2009d9f3f4efa688
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux · alpine · musl x64 cargo
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-09-19 |
Cas
HOW- Objectif
- verify pkg:cargo/base64@0.22.1
- Paquets
- Créé
- 2026-09-18T11:10:33Z
Contrat
- STANDARD encodes byte slice to canonical base64 string with padding
- STANDARD decodes valid base64 string with padding back to bytes
- STANDARD_NO_PAD encodes without padding and rejects input with padding
- URL_SAFE encodes using url-safe alphabet without plus or slash
- URL_SAFE_NO_PAD encodes and decodes url-safe base64 without padding
- decode returns InvalidLength error when base64 string has invalid length
- decode returns InvalidByte error when input contains non-base64 character
- encode_slice and decode_slice operate on preallocated buffers without allocation
Fichiers
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Code 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 = "sample-base64"
version = "1.0.0"
dependencies = [
"base64",
]
[package]
name = "sample-base64"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
base64 = "=0.22.1"
[[bin]]
name = "contract"
path = "test/contract.rs"
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 pkg:cargo/base64@0.22.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/base64@0.22.1
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:13d15ba9610e39502a872fbf9b1fc4fad4166d7e443769b2dfb06b9ffcce5973","contract":["STANDARD encodes byte slice to canonical base64 string with padding","STANDARD decodes valid base64 string with padding back to bytes","STANDARD_NO_PAD encodes without padding and rejects input with padding","URL_SAFE encodes using url-safe alphabet without plus or slash","URL_SAFE_NO_PAD encodes and decodes url-safe base64 without padding","decode returns InvalidLength error when base64 string has invalid length","decode returns InvalidByte error when input contains non-base64 character","encode_slice and decode_slice operate on preallocated buffers without allocation"],"goal":"verify pkg:cargo/base64@0.22.1","kind":"HOW","packages":["pkg:cargo/base64@0.22.1"],"schemaVersion":1},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/base64@0.22.1"],"schemaVersion":1,"subject":"pkg:cargo/base64@0.22.1","verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify pkg:cargo/base64@0.22.1",
"kind": "HOW",
"packages": [
"pkg:cargo/base64@0.22.1"
]
}
//! Clean-room verification sample for base64.
pub use base64::*;
use base64::engine::general_purpose::{
STANDARD, STANDARD_NO_PAD, URL_SAFE, URL_SAFE_NO_PAD,
};
use base64::prelude::*;
use base64::DecodeError;
fn main() {
// 1. STANDARD encodes byte slice to canonical base64 string with padding
let data = b"Hello, CodeSampleX!";
let encoded = STANDARD.encode(data);
assert_eq!(encoded, "SGVsbG8sIENvZGVTYW1wbGVYIQ==");
// 2. STANDARD decodes valid base64 string with padding back to bytes
let decoded = STANDARD.decode(&encoded).expect("valid decode");
assert_eq!(decoded, data);
// 3. STANDARD_NO_PAD encodes without padding and rejects input with padding
let encoded_no_pad = STANDARD_NO_PAD.encode(data);
assert_eq!(encoded_no_pad, "SGVsbG8sIENvZGVTYW1wbGVYIQ");
let pad_err = STANDARD_NO_PAD.decode(&encoded);
assert_eq!(pad_err, Err(DecodeError::InvalidPadding));
// 4. URL_SAFE encodes using url-safe alphabet without plus or slash
let url_data = b"\xfb\xff\xfe\x00\x01";
let url_encoded = URL_SAFE.encode(url_data);
assert!(!url_encoded.contains('+'));
assert!(!url_encoded.contains('/'));
assert_eq!(URL_SAFE.decode(&url_encoded).unwrap(), url_data);
// 5. URL_SAFE_NO_PAD encodes and decodes url-safe base64 without padding
let url_no_pad = URL_SAFE_NO_PAD.encode(url_data);
assert!(!url_no_pad.contains('='));
assert_eq!(URL_SAFE_NO_PAD.decode(&url_no_pad).unwrap(), url_data);
// 6. decode returns InvalidLength error when base64 string has invalid length
let invalid_len = STANDARD.decode("A");
assert_eq!(invalid_len, Err(DecodeError::InvalidLength(1)));
// 7. decode returns InvalidByte error when input contains non-base64 character
let invalid_byte = STANDARD.decode("SGVsbG8*");
assert_eq!(invalid_byte, Err(DecodeError::InvalidByte(7, b'*')));
// 8. encode_slice and decode_slice operate on preallocated buffers without allocation
let mut enc_buf = [0u8; 32];
let enc_len = STANDARD.encode_slice(b"test", &mut enc_buf).expect("encode slice");
assert_eq!(&enc_buf[..enc_len], b"dGVzdA==");
let mut dec_buf = [0u8; 4];
let dec_len = STANDARD.decode_slice(b"dGVzdA==", &mut dec_buf).expect("decode slice");
assert_eq!(dec_len, 4);
assert_eq!(&dec_buf, b"test");
println!("All base64 contract assertions passed successfully.");
}
Seeder d'origine
anonyme