hash (MD5)

MD5 hashing toolset backed by CryptoJS.MD5, producing 32-char lowercase hex strings. Both functions are auto-imported. The framework uses them internally for scenarios such as chunked-upload file verification (createUploader).

⚠️ MD5 is for non-security scenarios only (dedup, signature concatenation, cache keys). Never use it for passwords / sensitive digests — MD5 is collision-broken and not a cryptographically secure hash.

API

FunctionSignatureNotes
md5(input: string) => stringString → 32-char hex MD5
md5File(file: File) => Promise<string>Reads the whole file; suitable for small files (< a few MB)

Examples

Live string md5 + file md5File

加载中...
// String MD5 (signature concatenation)
const sig = md5(`${timestamp}${nonce}${apiKey}`)

// Full MD5 of a small image (verification param for chunked upload)
const fingerprint = await md5File(imageFile)

Caveats

  • md5File is based on File.arrayBuffer() and is browser only; SSR has no File and no business reason to hash files anyway.
  • md5 is pure computation — callable on both server and client.

Full-file fingerprints: hashFile

Computes full-file MD5 and SHA-256 incrementally in a browser Worker using 2MiB reads, without loading the whole file on the main thread. Returns lowercase hex { md5, sha256 }. Auto-imported, browser only; unsupported Workers cause an error. signal cancels hashing and terminates the Worker. onProgress(bytes) reports bytes read, not upload progress.

const controller = new AbortController()
const digest = await hashFile(file, {
  signal: controller.signal,
  onProgress: (bytes) => (progress.value = bytes / file.size),
})