5

How can I find the SHA256 hash of a webpage using Linux tools (CURL, etc.)?

4
  • This is offtopic here at AskUbuntu. I would consult the cryptography stackexchange.
    – negusp
    Oct 26, 2016 at 23:52
  • @PatrickNegus My bad, I should've posted this elsewhere. I came here out of habit... Oct 27, 2016 at 0:10
  • That's fine. At least you got your answer :)
    – negusp
    Oct 27, 2016 at 0:11
  • 1
    @PatrickNegus: Why? Downloading web resources and calculating checksums are both common things to do on a Linux/Ubuntu system and on topic here. Oct 27, 2016 at 10:24

1 Answer 1

11

Yeah, you can use curl and sha256sum in a single command, like so:

curl www.google.com | sha256sum

Which will give:

┌─[✗]─[16:51:49]─[kazwolfe@BlackHawk]
└──> lib $ curl www.google.com | sha256sum
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10221    0 10221    0     0  15500      0 --:--:-- --:--:-- --:--:-- 15509
803d9c7538817dd8b44f0f2b3990ced288413a1b5a6d042d4216170b065e432b  -

Your SHA256 sum will be present down below, as the long string of hex code gibberish stuff below the curl status output.

This works because cURL will push the website's content to something known as STDOUT, which typically gets shown to the terminal. However, when you use the pipe symbol (|), you redirect STDOUT of one program to the STDIN of another. Therefore, sha256sum is reading STDIN from the cURL command, which is then being used to actually compute the SHA256 value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.