Files
scriptc/tests/corpus/crypto-hash-optional-input.ts
Chris Tate ee9f0d64eb feat: ship the self-hosted native scriptc CLI (#585)
* feat: ship the self-hosted native scriptc CLI

- Run the shared compiler and CLI natively, including library builds and compile-time evaluation.
- Install native platform packages and ship relocatable standalone distributions.
- Preserve program semantics and reuse validated build artifacts for fast rebuilds.

* fix: complete native CLI integration and validation

- Preserve library diagnostics and run recursive compiler work on the main stack.
- Restore packaged helper permissions and exercise native npm and Wasm library builds.
- Recover interrupted Sandbox status probes within the original command deadline.
2026-09-30 02:17:56 -05:00

18 lines
806 B
TypeScript

import { createHash, createHmac } from "node:crypto";
const environment: Record<string, string | undefined> = { present: "hello" };
for (const name of ["present", "missing"]) {
const value = environment[name];
const text: string = value ?? "";
console.log(createHash("sha256").update(text).digest("hex"));
console.log(createHmac("sha256", "secret").update(text).digest("hex"));
if (value !== undefined) console.log(createHash("sha256").update(value).digest("hex"));
}
const buffers: (Buffer | undefined)[] = [Buffer.from("hello"), undefined];
for (let index = 0; index < buffers.length; index++) {
const buffer = buffers[index] ?? Buffer.from("");
console.log(createHash("sha256").update(buffer).digest("hex"));
console.log(createHmac("sha256", "secret").update(buffer).digest("hex"));
}