0

How does openssl perform hashing on stdin when multiple inputs are provided?

For example if the command entered is:
openssl {enter}
sha256 {enter}
foo {enter}
bar {enter}
foobar {enter}
ctrl + d

The resulting hash I'm receiving is 3e76042553dc7a71401dea0cd9b0b38b but that doesn't match any of the hashes that result from the individual words themselves when run separately.


foo - d3b07384d113edec49eaa6238ad5ff00
bar - c157a79031e1c40f85931829bc5fc552
foobar - 14758f1afd44c09b7992073ccf00b43d

How does that work?

bbeckca
  • 41
  • 3
  • 1
    The data that is hashed always consists of all of stdin until EOF is reached. – President James K. Polk Oct 21 '19 at 01:34
  • 1
    You're doing something wrong here. A SHA256 hash consists of 64 hex digits. Yours have only 32 digits, so these are not SHA256 hashes. But whatever hash function you're using, openssl will most likely calculate it using the input value `foo\nbar\nfoobar\n`. – r3mainer Oct 21 '19 at 07:58

0 Answers0