A very similar question has already been answered on Unix & Linux Stackexchange.
wget -O - http://example.com/file | tee file | md5sum > file.md5
Just replace the md5sum with sha1sum and it should work. Note that the proposed solution works only with *nix operating systems - getting it to work within Windows might be a challenge (but the Bash Subsystem for Windows or Cygwin might work for you).
Edit:
As I was asked in the comments how this works, I'll explain it here:
wget -O - http://example.com/file downloads the file (in sequential order) and outputs its content on the console. The pipe | allows me to forward this data to the next program: tee file stores the output of wget into the file file and forwards the data to the last program in the chain. md5sum > file.md5 calculates the md5-hash and stores it in file.md5.
Performance: (YMMV!)
- Downloading a big file (4GB) from a local server takes roughly 80 seconds
- Calculating the hash of the file (when stored locally) takes 70 seconds
- Doing both simultaneously takes again 80 seconds, resulting in a speed boost of almost 50%.
nicethe checksum process to avoid too much CPU on a large file. – vfclists Sep 26 '16 at 18:59