proomt

Search

Search posts, papers, and topics

All posts

SitePointJhon-Harry5 min readtutorialintermediate

How to Build a Browser-Based File Integrity Checker with JavaScript

Summary

The article walks through building a browser‑based file integrity checker that reads a file, computes its SHA‑256 hash with the Web Crypto API, and compares it to a trusted hash supplied by the user. It also covers handling large files, accessibility, and the security limits of client‑side hashing.

  • Use `crypto.subtle.digest('SHA-256', file.arrayBuffer())` to compute a hash entirely in the browser.
  • Normalize the expected hash (trim, lowercase, remove whitespace) before comparing to avoid false mismatches.
  • Validate file size (e.g., limit to 100 MB) and enforce a 64‑character hex pattern to catch bad input early.
  • Leverage the Clipboard API (`navigator.clipboard.writeText`) for easy copying of the calculated hash, with a manual fallback.

Frontend developers who need to verify downloaded files without server round‑trips should care, because it shows how to implement client‑side integrity checks securely.

6/10

Related reading

  1. WebAuthn Passkey Recovery: Building Account Fallbacks and Backup Codes in Node.js

    A step‑by‑step tutorial for building a zero‑trust WebAuthn passkey recovery flow in Node.js/TypeScript. It covers generating 128‑bit backup codes, hashing them with Argon2id, rate‑limited verification, time‑boxed JWT recovery sessions, and orchestrating new credential registration with @simplewebauthn/server while revoking lost credentials and rotating codes.

    SitePointsitepoint.com19 min
  2. Put App Documents in the System File Browser

    Codename One adds a read‑only DocumentProvider API that lets apps publish a virtual file tree to iOS Files and Android’s storage picker. The tree is defined with `DocumentNode` objects, can include remote‑only entries, and is shared via an App Group container. The iOS extension runs in a separate process, so the model is serialized and read independently; Android uses the same model inside the ap…

    CodeName Onecodenameone.com4 min
  3. SQLite Across Every Port: One Contract, One Encrypted File Format

    Codename One now ships a single, tested SQLite contract that works natively on Android, iOS, Windows, Linux, and in browsers via WebAssembly, with built‑in SQLCipher‑4 encryption supporting three key models. A conformance suite guarantees identical behavior across platforms, and migration helpers let legacy apps opt‑in. The update also adds a proper watch‑app model, DOM‑based text for JavaScript,…

    CodeName Onecodenameone.com11 min