Bug 236663 - md5/sha256/etc incorrect hash from stdin
Summary: md5/sha256/etc incorrect hash from stdin
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-20 14:24 UTC by Jeremy Faulkner
Modified: 2019-03-20 15:08 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Faulkner 2019-03-20 14:24:36 UTC
$ echo abc|md5
0bee89b07a248e27c83fc3d5951213c1
$ echo abc |md5
0bee89b07a248e27c83fc3d5951213c1
$ md5 -sabc
MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
$ echo abc > ~/test.md5
$ md5 ~/test.md5
MD5 (/home/gldisater/test.md5) = 0bee89b07a248e27c83fc3d5951213c1


$ sha256 -sabc
SHA256 ("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
$ echo abc| sha256
edeaaff3f1774ad2888673770c6d64097e391bc362d7d6fb34982ddf0efd18cb
Comment 1 Jeremy Faulkner 2019-03-20 14:32:08 UTC
Occurs on 13-CURRENT r345101 and 12-STABLE r344436
Comment 2 fullermd 2019-03-20 15:00:17 UTC
It's nothing to do with stdin.  echo(1) adds a newline (unless you `echo -n`); you're hashing a different string.

% printf "abc" | md5
900150983cd24fb0d6963f7d28e17f72

% printf "abc\n" | md5
0bee89b07a248e27c83fc3d5951213c1