Пример
base64 0.22.1
Проверенный пример — cargo base64 0.22.1. Контракт выполнен на rust 1 · linux alpine/x64 · docker и пройден: STANDARD encodes byte slice to canonical base64…
sha256:64814337588f49af8cf151990735192fa06f495771edef8e2009d9f3f4efa688
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 1
- Ключи подписи, собравшие его
- 1
Заявленная среда
linux · alpine · musl x64 cargo
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| 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 |
Кейс
HOW- Цель
- verify pkg:cargo/base64@0.22.1
- Пакеты
- Создан
- 2026-09-18T11:10:33Z
Контракт
- 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
Файлы
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
Исходный код
# 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.");
}
Исходный сидер
аноним