Beispiel
crc-32 1.2.2: bstr
Verifiziertes Beispiel für npm crc-32 1.2.2: bstr. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand: CRC32.bstr(binaryStr) computes…
sha256:fac6a21f7d1986f3cd51e6a9e225f97dd5ad59de25e451c2af9cc7270f1de0a8
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
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 npm
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-04 |
Fall
HOW- Ziel
- verify crc-32.bstr in pkg:npm/crc-32@1.2.2
- Pakete
- Symbole
-
- crc-32.bstr
- Erstellt
- 2026-09-04T12:56:27Z
Contract
- CRC32.bstr(binaryStr) computes 32-bit signed integer CRC-32 checksum for 8-bit binary strings
- CRC32.bstr('') returns 0 for empty binary string
- CRC32.bstr(binaryStr) matches CRC32.buf(bytes) for identical byte sequences
- CRC32.bstr(part2, seed) supports incremental CRC-32 computation chaining with seed
Dateien
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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 crc-32.bstr in pkg:npm/crc-32@1.2.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/crc-32@1.2.2
Demonstrate these symbols/APIs:
- crc-32.bstr
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:4c47c50ecfc83b2a5bfb7d76cdda9462f091ee52033d676ff66f2ebc5da83db7","contract":["CRC32.bstr(binaryStr) computes 32-bit signed integer CRC-32 checksum for 8-bit binary strings","CRC32.bstr('') returns 0 for empty binary string","CRC32.bstr(binaryStr) matches CRC32.buf(bytes) for identical byte sequences","CRC32.bstr(part2, seed) supports incremental CRC-32 computation chaining with seed"],"goal":"verify crc-32.bstr in pkg:npm/crc-32@1.2.2","kind":"HOW","packages":["pkg:npm/crc-32@1.2.2"],"schemaVersion":1,"symbols":["crc-32.bstr"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/crc-32@1.2.2"],"schemaVersion":1,"subject":"pkg:npm/crc-32@1.2.2","symbols":["crc-32.bstr"],"verifierAdapter":"node-typescript@1"}
import CRC32 from 'crc-32';
/**
* Computes the 32-bit signed CRC-32 checksum of an 8-bit binary string.
* Each character code is treated as a single byte (0-255).
*
* @param {string} bstr - Binary string of 8-bit characters.
* @param {number} [seed] - Optional previous CRC-32 value for incremental calculation.
* @returns {number} 32-bit signed integer CRC-32 checksum.
*/
export function crc32BinaryString(bstr, seed) {
return CRC32.bstr(bstr, seed);
}
/**
* Converts a signed 32-bit CRC integer to an unsigned 32-bit integer.
*
* @param {number} crc - 32-bit signed integer CRC.
* @returns {number} 32-bit unsigned integer.
*/
export function toUnsigned(crc) {
return crc >>> 0;
}
/**
* Formats a 32-bit CRC checksum as an 8-character zero-padded lowercase hexadecimal string.
*
* @param {number} crc - 32-bit signed or unsigned integer CRC.
* @returns {string} 8-character hex string.
*/
export function toHex(crc) {
return (crc >>> 0).toString(16).padStart(8, '0');
}
{
"name": "sample-crc-32-bstr",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-crc-32-bstr",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"crc-32": "1.2.2"
}
},
"node_modules/crc-32": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz",
"integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==",
"license": "Apache-2.0",
"bin": {
"crc32": "bin/crc32.njs"
},
"engines": {
"node": ">=0.8"
}
}
}
}
{
"name": "sample-crc-32-bstr",
"version": "1.0.0",
"type": "module",
"private": true,
"license": "MIT-0",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"crc-32": "1.2.2"
}
}
{
"schemaVersion": 1,
"goal": "verify crc-32.bstr in pkg:npm/crc-32@1.2.2",
"kind": "HOW",
"packages": [
"pkg:npm/crc-32@1.2.2"
],
"symbols": [
"crc-32.bstr"
]
}
import assert from 'node:assert/strict';
import CRC32 from 'crc-32';
import { crc32BinaryString, toUnsigned, toHex } from '../index.mjs';
// 1. Verify CRC32.bstr computes 32-bit signed integer CRC-32 checksum for 8-bit binary strings
const binaryData = [0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64];
const binaryStr = String.fromCharCode(...binaryData);
const checksum = CRC32.bstr(binaryStr);
assert.equal(typeof checksum, 'number');
assert.equal(checksum, 0x4a17b156 | 0);
assert.equal(toUnsigned(checksum), 0x4a17b156);
assert.equal(toHex(checksum), '4a17b156');
assert.equal(crc32BinaryString(binaryStr), checksum);
// 2. Verify CRC32.bstr('') returns 0 for empty binary string
assert.equal(CRC32.bstr(''), 0);
assert.equal(crc32BinaryString(''), 0);
// 3. Verify CRC32.bstr matches CRC32.buf for identical byte sequences
const highByteData = [0x00, 0x01, 0x7f, 0x80, 0xaa, 0xfe, 0xff];
const highByteStr = String.fromCharCode(...highByteData);
const highByteBuf = Buffer.from(highByteData);
const bstrResult = CRC32.bstr(highByteStr);
const bufResult = CRC32.buf(highByteBuf);
assert.equal(bstrResult, bufResult);
assert.equal(crc32BinaryString(highByteStr), bufResult);
// 4. Verify CRC32.bstr(part2, seed) supports incremental CRC-32 chaining with seed
const chunk1 = String.fromCharCode(0x01, 0x02, 0x03);
const chunk2 = String.fromCharCode(0x04, 0x05, 0x06);
const whole = String.fromCharCode(0x01, 0x02, 0x03, 0x04, 0x05, 0x06);
const wholeCrc = CRC32.bstr(whole);
const seed1 = CRC32.bstr(chunk1);
const chainedCrc = CRC32.bstr(chunk2, seed1);
assert.equal(chainedCrc, wholeCrc);
assert.equal(crc32BinaryString(chunk2, crc32BinaryString(chunk1)), wholeCrc);
console.log('Contract assertions passed successfully.');
Ursprungs-Seeder
anonym