diff --git a/lib/cli/etcher.js b/lib/cli/etcher.js index d3ba3ecb..e027e0f5 100644 --- a/lib/cli/etcher.js +++ b/lib/cli/etcher.js @@ -90,8 +90,8 @@ permissions.isElevated().then((elevated) => { return Bluebird.try(() => { console.log(messages.info.flashComplete(path.basename(results.imagePath), results.flash.drive)) - if (results.flash.checksum.crc32) { - console.log(`Checksum: ${results.flash.checksum.crc32}`) + if (results.flash.checksum.md5) { + console.log(`Checksum: ${results.flash.checksum.md5}`) } return Bluebird.resolve() diff --git a/lib/cli/writer.js b/lib/cli/writer.js index 378e8528..d8424516 100644 --- a/lib/cli/writer.js +++ b/lib/cli/writer.js @@ -49,7 +49,7 @@ exports.writeImage = (imagePath, drive, options, onProgress) => { path: drive, imagePath, verify: options.validateWriteOnSuccess, - checksumAlgorithms: [ 'crc32' ], + checksumAlgorithms: [ 'md5' ], unmountOnSuccess: options.unmountOnSuccess }) diff --git a/lib/sdk/writer/checksum-stream.js b/lib/sdk/writer/checksum-stream.js index 1e9585b8..68e33cee 100644 --- a/lib/sdk/writer/checksum-stream.js +++ b/lib/sdk/writer/checksum-stream.js @@ -18,26 +18,8 @@ const stream = require('readable-stream') const crypto = require('crypto') -const CRC32Stream = require('crc32-stream') const _ = require('lodash') -/** - * @summary Get a hash stream - * @function - * @private - * @example - * var md5Stream = getHashStream('md5') - * - * @param {String} algorithm - either `crc32` or anything supported by `crypto.Hash` - * @returns {Stream.Transform} - */ -const getHashStream = (algorithm) => { - if (algorithm === 'crc32') { - return new CRC32Stream() - } - return crypto.createHash(algorithm) -} - /** * @summary Create an instance of ChecksumStream * @name ChecksumStream @@ -52,13 +34,12 @@ class ChecksumStream extends stream.Transform { * @param {String[]} options.algorithms - hash algorithms * @example * var checksum = new ChecksumStream({ - * algorithms: [ 'crc32', 'md5' ] + * algorithms: [ 'md5' ] * }) * * checksum.once('checksum', (checksum) => { * // checksum: { - * // crc32: 'EF28AF1C', - * // md5: '' + * // md5: '55a4eb779e08f604c41ba1cbfff47ada' * // } * }) * @@ -85,7 +66,7 @@ class ChecksumStream extends stream.Transform { * const hash = this._createHash(algorithm) */ _createHash (algorithm) { - const hash = _.attempt(getHashStream, algorithm) + const hash = _.attempt(crypto.createHash, algorithm) if (_.isError(hash)) { hash.message += ` "${algorithm}"` @@ -108,18 +89,10 @@ class ChecksumStream extends stream.Transform { return this.emit('error', error) }) - if (algorithm === 'crc32') { - hash.once('end', () => { - this.results[algorithm] = hash.digest('hex') - check() - }) - hash.resume() - } else { - hash.once('readable', () => { - this.results[algorithm] = hash.read().toString('hex') - check() - }) - } + hash.once('readable', () => { + this.results[algorithm] = hash.read().toString('hex') + check() + }) return hash }