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

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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');

オリジンシーダー

匿名