CodeSampleX

Beispiel

github.com/cespare/xxhash/v2 v2.1.1: Sum64String

Verifiziertes Beispiel für golang github.com/cespare/xxhash/v2 v2.1.1: Sum64String. Der Vertrag lief auf go 1.26 · linux alpine/x64 · docker und bestand.

sha256:c2fd8fc07474fb7456abf494eb824830fd8ec05d66bfade9c0fd230c9620acc7

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
2
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 go

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
go 1.26 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26-alpine@sha256:28d89ee9cc0f…
2026-08-26
go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a…
2026-09-07

Fall

HOW
Ziel
verify Sum64String in pkg:golang/github.com/cespare/xxhash/v2@v2.1.1
Pakete
Symbole
  • Sum64String
Erstellt
2026-08-26T01:16:18Z

Contract

  1. xxhash.Sum64String computes the 64-bit xxHash checksum of a string matching xxhash.Sum64 of the equivalent byte slice
  2. xxhash.Sum64String produces deterministic non-zero checksum for non-empty string and distinct hashes for distinct string inputs
  3. xxhash.Sum64String correctly computes the hash of an empty string

Dateien

  • PROMPT.md
  • csx.json
  • go.mod
  • go.sum
  • main.go
  • spec.json
  • test/contract.go

Quellartefakt herunterladen (tar.gz)

Quelltext

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 Sum64String in pkg:golang/github.com/cespare/xxhash/v2@v2.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:golang/github.com/cespare/xxhash/v2@v2.1.1
Demonstrate these symbols/APIs:
  - Sum64String

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:0bd935df081559214d3814e4fa32c77a5f85b9cc33309f8862dcfbd6cb829cb0","contract":["xxhash.Sum64String computes the 64-bit xxHash checksum of a string matching xxhash.Sum64 of the equivalent byte slice","xxhash.Sum64String produces deterministic non-zero checksum for non-empty string and distinct hashes for distinct string inputs","xxhash.Sum64String correctly computes the hash of an empty string"],"goal":"verify Sum64String in pkg:golang/github.com/cespare/xxhash/v2@v2.1.1","kind":"HOW","packages":["pkg:golang/github.com/cespare/xxhash/v2@v2.1.1"],"schemaVersion":1,"symbols":["Sum64String"]},"contractCommand":["go","run","./test"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/cespare/xxhash/v2@v2.1.1"],"schemaVersion":1,"subject":"pkg:golang/github.com/cespare/xxhash/v2@v2.1.1","symbols":["Sum64String"],"verifierAdapter":"golang@1"}
go.mod
module example.com/sample

go 1.26.6

require github.com/cespare/xxhash/v2 v2.1.1
go.sum
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
main.go
package main

import (
	"fmt"

	"github.com/cespare/xxhash/v2"
)

func main() {
	input := "hello world"
	hashString := xxhash.Sum64String(input)
	hashBytes := xxhash.Sum64([]byte(input))

	fmt.Printf("xxhash.Sum64String(%q) = %016x\n", input, hashString)
	fmt.Printf("xxhash.Sum64([]byte(%q)) = %016x\n", input, hashBytes)
	fmt.Printf("Equal: %t\n", hashString == hashBytes)
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify Sum64String in pkg:golang/github.com/cespare/xxhash/v2@v2.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:golang/github.com/cespare/xxhash/v2@v2.1.1"
  ],
  "symbols": [
    "Sum64String"
  ]
}
test/contract.go
package main

import (
	"fmt"
	"os"

	"github.com/cespare/xxhash/v2"
)

func main() {
	// Assertion 1: xxhash.Sum64String computes the 64-bit xxHash checksum of a string matching xxhash.Sum64 of the equivalent byte slice
	testStrings := []string{
		"",
		"a",
		"hello world",
		"The quick brown fox jumps over the lazy dog",
		"Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
	}

	for _, s := range testStrings {
		hStr := xxhash.Sum64String(s)
		hBytes := xxhash.Sum64([]byte(s))
		if hStr != hBytes {
			fmt.Fprintf(os.Stderr, "FAIL: Sum64String(%q) = %d != Sum64([]byte) = %d\n", s, hStr, hBytes)
			os.Exit(1)
		}
	}

	// Assertion 2: xxhash.Sum64String produces deterministic non-zero checksum for non-empty string and distinct hashes for distinct string inputs
	h1 := xxhash.Sum64String("test-input-1")
	h1Repeat := xxhash.Sum64String("test-input-1")
	h2 := xxhash.Sum64String("test-input-2")

	if h1 == 0 {
		fmt.Fprintf(os.Stderr, "FAIL: Sum64String produced unexpected zero hash for non-empty string\n")
		os.Exit(1)
	}
	if h1 != h1Repeat {
		fmt.Fprintf(os.Stderr, "FAIL: Sum64String is not deterministic: %d != %d\n", h1, h1Repeat)
		os.Exit(1)
	}
	if h1 == h2 {
		fmt.Fprintf(os.Stderr, "FAIL: Sum64String collision for distinct inputs %d == %d\n", h1, h2)
		os.Exit(1)
	}

	// Assertion 3: xxhash.Sum64String correctly computes the hash of an empty string
	hEmpty := xxhash.Sum64String("")
	hEmptyBytes := xxhash.Sum64([]byte{})
	if hEmpty != hEmptyBytes {
		fmt.Fprintf(os.Stderr, "FAIL: Sum64String(\"\") = %d != Sum64([]byte{}) = %d\n", hEmpty, hEmptyBytes)
		os.Exit(1)
	}
	if hEmpty != 17241709254077376921 {
		fmt.Fprintf(os.Stderr, "FAIL: Sum64String(\"\") expected 17241709254077376921, got %d\n", hEmpty)
		os.Exit(1)
	}
}

Ursprungs-Seeder

anonym