import { MD5Result } from './md5-stream.cjs'; export { MD5Stream, createMD5Stream, fromStream, pipeThroughMD5 } from './md5-stream.cjs'; import { Readable } from 'stream'; export { MD5ReadableStream, MD5ReadableStreamOptions, consumeWithMD5, createMD5ReadableStream, hashBlob, hashFile as hashFileWHATWG, hashReadableStream } from './whatwg-stream.cjs'; /** * File System Utilities for MD5 hashing * Provides convenient utilities for hashing files through Node.js file system streams */ /** * Options for file hashing operations */ interface HashFileOptions { /** * Chunk size for reading file (default: 64KB) */ chunkSize?: number; /** * Progress callback for tracking hashing progress * @param current - Current position in bytes */ onProgress?: (current: number) => void; } /** * Hash a file by its path * @param filePath - Path to the file to hash * @param options - Optional configuration * @returns Promise with MD5 result (digest and bytes processed) * * @example * ```ts * import { hashFile } from 'pure-md5'; * * const result = await hashFile('path/to/file.txt'); * console.log('MD5:', result.digest); * console.log('Bytes:', result.bytesProcessed); * ``` */ declare function hashFile(filePath: string, options?: HashFileOptions): Promise; /** * Hash data from an existing readable stream * @param readStream - Readable stream to hash * @param options - Optional configuration * @returns Promise with MD5 result (digest and bytes processed) * * @example * ```ts * import { createReadStream } from 'fs'; * import { hashFileStream } from 'pure-md5'; * * const stream = createReadStream('path/to/file.txt'); * const result = await hashFileStream(stream); * console.log('MD5:', result.digest); * ``` */ declare function hashFileStream(readStream: Readable, options?: { onProgress?: (current: number) => void; totalSize?: number; }): Promise; /** * Hash a file and return only the hex digest * @param filePath - Path to the file to hash * @param options - Optional configuration * @returns Promise with MD5 hex digest string * * @example * ```ts * import { hashFileDigest } from 'pure-md5'; * * const digest = await hashFileDigest('path/to/file.txt'); * console.log('MD5:', digest); * ``` */ declare function hashFileDigest(filePath: string, options?: HashFileOptions): Promise; /** * Hash a file stream and return only the hex digest * @param readStream - Readable stream to hash * @param options - Optional configuration * @returns Promise with MD5 hex digest string */ declare function hashFileStreamDigest(readStream: Readable, options?: { onProgress?: (current: number) => void; totalSize?: number; }): Promise; /** * Verify file integrity by comparing MD5 hash * @param filePath - Path to the file to verify * @param expectedDigest - Expected MD5 hex digest * @param options - Optional configuration * @returns Promise with verification result * * @example * ```ts * import { verifyFile } from 'pure-md5'; * * const isVerified = await verifyFile( * 'path/to/file.txt', * '5d41402abc4b2a76b9719d911017c592' * ); * console.log('Verified:', isVerified); * ``` */ declare function verifyFile(filePath: string, expectedDigest: string, options?: HashFileOptions): Promise; /** * Get MD5 hash of a file synchronously (not recommended for large files) * @param filePath - Path to the file to hash * @returns MD5 hex digest string * * @example * ```ts * import { hashFileSync } from 'pure-md5'; * * const digest = hashFileSync('path/to/file.txt'); * console.log('MD5:', digest); * ``` */ declare function hashFileSync(filePath: string): string; /** * Utility to create a progress tracker for file hashing * @param totalSize - Total size of the file being hashed * @param onUpdate - Callback with progress percentage (0-100) * @returns Progress callback function * * @example * ```ts * import { hashFile, createProgressTracker } from 'pure-md5'; * * const totalSize = 1024 * 1024 * 100; // 100MB * const progress = createProgressTracker(totalSize, (percent) => { * console.log(`Progress: ${percent.toFixed(1)}%`); * }); * * const result = await hashFile('large-file.bin', { onProgress: progress }); * ``` */ declare function createProgressTracker(totalSize: number, onUpdate: (percentage: number) => void): (current: number) => void; export { type HashFileOptions, MD5Result, createProgressTracker, hashFile, hashFileDigest, hashFileStream, hashFileStreamDigest, hashFileSync, verifyFile };