SHAGenerator
Practical Guides

How File Hashing Works.

The engineering behind client-side file hashing: Web Streams, ArrayBuffers, chunked incremental updates, and how to hash large files in a browser without memory exhaustion.

Category: Practical GuidesReading Time: 6 min readPublished: 2026-08-20

1. The Memory Exhaustion Problem

Attempting to read an entire 5 GB ISO file into browser memory with `FileReader.readAsArrayBuffer` will immediately exhaust browser tab memory and trigger an Out-Of-Memory (OOM) crash.

2. The Streaming Chunked Solution

Modern file hashing slices the `File` object into 2MB sequential chunks using the HTML5 File API and Web Streams. Each chunk is fed into an incremental hash accumulator, then garbage collected before the next slice is read, keeping tab memory usage under 20MB even for 50GB files.
JAVASCRIPTSyntax Example
const chunkSize = 2 * 1024 * 1024; // 2MB
let offset = 0;
const hasher = sha256.create();

while (offset < file.size) {
  const slice = file.slice(offset, offset + chunkSize);
  const buffer = await slice.arrayBuffer();
  hasher.update(new Uint8Array(buffer));
  offset += chunkSize;
}
const digest = hasher.digest();

3. Privacy Architecture

Because JavaScript reads data directly from your local disk using browser APIs, no bytes are uploaded over the network. File processing is 100% local to your device.

Frequently Asked Questions.

Frequently Asked Questions

Clear answers to common cryptographic and implementation questions.

Does SHAGenerator upload my files to any server?
No. All file streaming happens entirely in your local browser memory via JavaScript and Web Crypto APIs. Zero bytes are uploaded.

Recommended Tools for this Topic

View all tools →