Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get 2 different results when checking sha256sum of a file?

Tags:

I'm trying to get the checksum of a downloaded file, so I can ensure it gets deployed correctly from an ansible playbook. I discovered that I get two different results depending on whether I download the file first, or just check it via a pipe with curl.

Download and check:

$ wget https://github.com/drush-ops/drush/releases/download/8.1.15/drush.phar
$ sha256sum drush.phar 
6999d72e51577b1e20cfaec87152d9905b714f5812861692877b8424a4e2358a  drush.phar

Check piped from curl:

$ curl -s https://github.com/drush-ops/drush/releases/download/8.1.15/drush.phar| sha256sum
c703007cf15cbabbeb510031ded52e7482f85dd3cce037bf9bcb7d7749acaa23  -

You'd think they would be the same result?

like image 796
Dale Anderson Avatar asked Oct 12 '17 17:10

Dale Anderson


1 Answers

Mystery solved.

The original URL has redirects, which I need to tell curl to follow with the -L switch:

$ curl -sL https://github.com/drush-ops/drush/releases/download/8.1.15/drush.phar| sha256sum
6999d72e51577b1e20cfaec87152d9905b714f5812861692877b8424a4e2358a  -

Voila. Now the checksums match.

like image 123
Dale Anderson Avatar answered Oct 13 '22 18:10

Dale Anderson