How crash-predictor1/aviator-predictor works
Purpose and Scope
Despite the README’s predictor branding, the repository contents implement a TypeScript SHA hashing library and its distributable JavaScript bundles. It provides incremental and one-shot hashing for SHA-1, SHA-256, SHA-512, and SHA-3 families; no predictor application, AI service, seed-analysis workflow, backend, or mobile runtime is present in the tree.
Public Entry Points and Distribution
The source-level API is organized around algorithm modules, with the shared hash abstraction in src/sha.ts and individual exports in src/sha1.ts, src/sha256.ts, src/sha3.ts, and src/sha512.ts. Built outputs are committed under dist/, including browser/CommonJS-style JavaScript, ESM bundles, and TypeScript declarations such as dist/sha.js, dist/sha.mjs, and dist/sha.d.ts.
Hash Engine Core
src/sha.ts defines the common streaming hash lifecycle: initialize state, accept updates, finalize padding, and emit digests. src/common.ts supplies shared internal mechanics used across algorithms. The engine is designed around local, deterministic computation: input enters via update methods, is processed in blocks, then finalized into an encoded digest. There are no network, persistence, user-account, or external API boundaries.
Algorithm Families
Algorithm-specific implementations own compression rounds, initial state, block size, and digest behavior:
• SHA-1: src/sha1.ts
• SHA-2 256-bit family: src/sha256.ts
• SHA-2 512-bit family: src/sha512.ts
• SHA-3/Keccak family: src/sha3.ts
These modules sit above the common hash interface and select the word arithmetic appropriate to their algorithm.
Numeric and Encoding Boundaries
JavaScript bitwise operations are insufficient for full 64-bit SHA-512 state, so the code separates arithmetic primitives by word width: src/primitives_32.ts supports 32-bit algorithms, while src/primitives_64.ts supports paired/high-low 64-bit operations. Input/output representation conversion is centralized in src/converters.ts; internal type contracts are in src/custom_types.ts. This is the main correctness boundary between caller-provided strings/bytes and algorithm word state.
Build and Runtime Targets
The project is a Node.js/TypeScript package built with Rollup. rollup.config.mjs produces the committed dist/ JavaScript and module artifacts, while tsconfig.json governs source compilation. The package supports browser consumption as indicated by index.html and Karma configuration in karma.conf.js, alongside package consumers using ESM, JavaScript bundles, or declaration files. No server infrastructure or hosted service is defined.
Architectural Flow
A consumer imports an algorithm bundle from dist/ (or source module during development), creates or invokes a hash implementation, supplies data through the common update path, and receives a digest converted into the requested representation. The algorithm module delegates block operations to 32- or 64-bit primitives and shared conversion logic. Release artifacts preserve this API for JavaScript, ESM, and TypeScript consumers.
Main entry points: sha.ts Streaming hash lifecycle · rollup.config.mjs Rollup build · primitives_32.ts 32-bit primitives · sha.js JavaScript bundle
Components 17
TypeScript hash engine
- Streaming hash lifecycle · Initializes, updates, pads, and emits digests.
src/sha.ts - Shared hash mechanics
src/common.ts - SHA-1
src/sha1.ts - SHA-2 256-bit
src/sha256.ts - SHA-2 512-bit
src/sha512.ts - SHA-3 / Keccak
src/sha3.ts
Numeric and encoding
- 32-bit primitives
src/primitives_32.ts - 64-bit primitives · Supports SHA-512 high/low word operations.
src/primitives_64.ts - Input/output conversion · Converts caller strings and bytes to and from internal words.
src/converters.ts - Internal type contracts
src/custom_types.ts
Build and distribution
- Rollup build · Produces committed package artifacts.
rollup.config.mjs - TypeScript compilation
tsconfig.json - JavaScript bundle
dist/sha.js - ESM bundle
dist/sha.mjs - Type declarations
dist/sha.d.ts
Other components
- Package consumer · Uses one-shot or incremental hash APIs.
- Browser consumer
index.html
Connections 19
- Package consumer → JavaScript bundle: imports
- Package consumer → ESM bundle: imports
- Package consumer → Type declarations: types
- Browser consumer → JavaScript bundle: loads
- SHA-1 → Streaming hash lifecycle: uses lifecycle
- SHA-2 256-bit → Streaming hash lifecycle: uses lifecycle
- SHA-2 512-bit → Streaming hash lifecycle: uses lifecycle
- SHA-3 / Keccak → Streaming hash lifecycle: uses lifecycle
- Streaming hash lifecycle → Shared hash mechanics: shared block mechanics
- Streaming hash lifecycle → Input/output conversion: input and digest encoding
- SHA-1 → 32-bit primitives: 32-bit rounds
- SHA-2 256-bit → 32-bit primitives: 32-bit rounds
- SHA-2 512-bit → 64-bit primitives: 64-bit rounds
- SHA-3 / Keccak → 32-bit primitives: word operations
- Streaming hash lifecycle → Internal type contracts: contracts
- Rollup build → JavaScript bundle: builds
- Rollup build → ESM bundle: builds
- Rollup build → Type declarations: emits
- TypeScript compilation → Rollup build: governs source compilation