CodeSampleX

샘플

bun 1.3.14: CryptoHasher, CryptoHasher.update, CryptoHasher.digest

검증된 샘플 — npm bun 1.3.14: CryptoHasher, CryptoHasher.update, CryptoHasher.digest. bun 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:884a8685fa8d90916655ba691e2b11e038ba3c1e7a7ddc56adcd551085c8a05a

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
2
빌드한 서명 키
2
선언된 환경 bun 1 linux x64 bun 1 javascript bun

검증 실행 환경

환경 컨트랙트 단계 실행일
bun 1 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · npm@1
2026-08-19
bun 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · npm@1oven/bun:1-alpine@sha256:07235578f79e…
2026-09-07

케이스

HOW
목표
verify Bun.CryptoHasher in pkg:npm/bun@1.3.14
패키지
심벌
  • Bun.CryptoHasher
  • Bun.CryptoHasher.update
  • Bun.CryptoHasher.digest
환경
bun 1
생성일
2026-08-18T13:32:46Z

컨트랙트

  1. Bun.CryptoHasher computes cryptographic hashes natively with support for sha256, sha512, and md5 algorithms.
  2. Bun.CryptoHasher.update supports incremental streaming input chunks.
  3. Bun.CryptoHasher.digest returns raw Uint8Array, hex, and base64 encoded strings according to the requested encoding parameter.

파일

  • PROMPT.md
  • csx.json
  • package.json
  • spec.json
  • test/contract.mjs

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
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 Bun.CryptoHasher in pkg:npm/bun@1.3.14
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/bun@1.3.14
Demonstrate these symbols/APIs:
  - Bun.CryptoHasher
Required runtime conditions:
  - ecosystem: golang
  - language: go
  - packageManager: go@1.26.5
  - runtime: go@1.26.5

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.
csx.json
{"case":{"caseId":"case:sha256:1d2bc513cdb518046919a5375468fadccddb71a905c0d5340237cbb1c2a5e71f","contract":["Bun.CryptoHasher computes cryptographic hashes natively with support for sha256, sha512, and md5 algorithms.","Bun.CryptoHasher.update supports incremental streaming input chunks.","Bun.CryptoHasher.digest returns raw Uint8Array, hex, and base64 encoded strings according to the requested encoding parameter."],"goal":"verify Bun.CryptoHasher in pkg:npm/bun@1.3.14","kind":"HOW","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.CryptoHasher","Bun.CryptoHasher.update","Bun.CryptoHasher.digest"]},"contractCommand":["bun","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"bun","language":"javascript","moduleSystem":"esm","os":"linux","packageManager":"bun","runtime":"bun","runtimeVersion":"1","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.CryptoHasher","Bun.CryptoHasher.update","Bun.CryptoHasher.digest"],"verifierAdapter":"npm@1"}
package.json
{
  "name": "csx-bun-cryptohasher-contract",
  "version": "1.0.0",
  "private": true,
  "type": "module"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify Bun.CryptoHasher in pkg:npm/bun@1.3.14",
  "kind": "HOW",
  "packages": [
    "pkg:npm/bun@1.3.14"
  ],
  "symbols": [
    "Bun.CryptoHasher"
  ],
  "runtimeConditions": {
    "ecosystem": "golang",
    "language": "go",
    "packageManager": "go@1.26.5",
    "runtime": "go@1.26.5"
  }
}
test/contract.mjs
import assert from 'node:assert/strict';

assert.equal(typeof Bun, 'object', 'Bun global is present');
assert.equal(typeof Bun.CryptoHasher, 'function', 'Bun.CryptoHasher constructor is present');

// 1. Basic SHA-256 hashing
const hasher = new Bun.CryptoHasher('sha256');
hasher.update('hello world');
const hexDigest = hasher.digest('hex');
assert.equal(hexDigest, 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9');

// 2. Incremental streaming updates
const streamHasher = new Bun.CryptoHasher('sha256');
streamHasher.update('hello ');
streamHasher.update('world');
assert.equal(streamHasher.digest('hex'), 'b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9');

// 3. Binary Uint8Array digest
const rawHasher = new Bun.CryptoHasher('sha256');
rawHasher.update('hello world');
const rawDigest = rawHasher.digest();
assert(rawDigest instanceof Uint8Array);
assert.equal(rawDigest.length, 32);

// 4. Base64 encoding format
const b64Hasher = new Bun.CryptoHasher('sha256');
b64Hasher.update('hello world');
assert.equal(b64Hasher.digest('base64'), Buffer.from(rawDigest).toString('base64'));

// 5. Multiple hash algorithms (md5, sha512)
const md5Hasher = new Bun.CryptoHasher('md5');
md5Hasher.update('hello world');
assert.equal(md5Hasher.digest('hex'), '5eb63bbbe01eeed093cb22bb8f5acdc3');

const sha512Hasher = new Bun.CryptoHasher('sha512');
sha512Hasher.update('hello world');
assert.equal(sha512Hasher.digest('hex').length, 128);

console.log('CONTRACT PASS: Bun.CryptoHasher supports incremental hashing and multiple output encodings');

오리진 시더

익명