import { createHash } from 'crypto' ; import { createReadStream } from 'fs' ; import { finished } from 'stream' ; import { promisify } from 'util' ; export async function md5 ( path ) { const hash = createHash ( 'md5' ) ; const stream = createReadStream ( path ) ; stream . on ( 'data' , ( chunk ) => hash . update ( chunk ) ) ; await promisify ( finished ) ( stream , { writable : false } ) ; return hash . digest ( 'hex' ) ; }