Package Exports
- hash-stream-validation
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hash-stream-validation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hash-stream-validation
Hash a stream of data, then validate
$ npm install --save hash-stream-validationvar hashStreamValidation = require('hash-stream-validation');
var validateStream = hashStreamValidation();
fs.createReadStream(filePath)
.pipe(validateStream)
.on('data', function() { /*... */ })
.on('end', function() {
validateStream.test('md5', /*checksum*/);
});Use Case
After a successful upload to a Google Cloud Storage bucket, the API will respond with the hash of data it has received. During our upload, we can run the data through this module, then confirm after the upload if we both arrived at the same results. If not, we know something went wrong during the transmission.
API
validateStream = hashStreamValidation([opts])
opts.crc32c
- Type:
Boolean - Default:
true
Enable crc32c hashing via sse4_crc32.*
- Note: Any issues installing this module on your system should be opened at their repository.
opts.md5
- Type:
Boolean - Default:
true
Enable MD5 hashing.
validateStream.test(algo, sum)
algo
- Type:
String
The alogrithm to test the sum against ('crc32c' or 'md5').
sum
- Type:
String
The sum to validate.