| 123456789101112131415 |
- const crypto = require('crypto')
- const fs = require('fs')
- function calculateFileMD5(filePath) {
- return new Promise((resolve, reject) => {
- const hash = crypto.createHash('md5')
- const stream = fs.createReadStream(filePath)
- stream.on('data', (data) => hash.update(data))
- stream.on('end', () => resolve(hash.digest('hex')))
- stream.on('error', (error) => reject(error))
- })
- }
- module.exports = { calculateFileMD5 }
|